[vtkusers] Change Size of Axis Labels

shari1 at cs.umbc.edu shari1 at cs.umbc.edu
Thu Apr 30 16:12:33 EDT 2009


I am trying to make the labels on my axes in a vtkAxesActor smaller.  I
thought I understood how to do it, but it doesn't seem to be working - the
size never changes.  The code doesn't generate any errors (at least from
looking in the console window), but the labels stay the same size.  In
addition, bold, italics, and shadow seem to get turned on when I try to
change the size, which is not what I had in mind!  I've included just the
code for the stuff involving the axes below.  If someone could take a look
and help me figure out what I'm doing wrong, I'd really appreciate it.

Thanks,
Shari


import vtk

class Visualizer:
    def visualize(self):
        self.axesActor = vtk.vtkAxesActor()
        self.axesActor.SetXAxisLabelText("X Position")
        self.axesActor.SetYAxisLabelText("Y Position")
        self.axesActor.SetZAxisLabelText("Error")

        self.axesActor.SetShaftTypeToLine()
        self.axesActor.SetTotalLength(33.0, 33.0, 33.0)
        self.axesActor.SetNormalizedShaftLength(1.0, 1.0, 1.0)
        self.axesActor.SetNormalizedTipLength(0.05, 0.05, 0.05)

        xAxisLabel = self.axesActor.GetXAxisCaptionActor2D()
        xAxisLabel.GetCaptionTextProperty().SetFontSize(6)

        yAxisLabel = self.axesActor.GetYAxisCaptionActor2D()
        yAxisLabel.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
        yAxisLabel.GetPositionCoordinate().SetValue(-0.20, 0.05)
        yAxisLabel.GetCaptionTextProperty().SetFontSize(6)

        zAxisLabel = self.axesActor.GetZAxisCaptionActor2D()
        zAxisLabel.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
        zAxisLabel.GetPositionCoordinate().SetValue(0.00, -0.13)
        zAxisLabel.GetCaptionTextProperty().SetFontSize(6)

        ren = vtk.vtkRenderer()

        # Create the RenderWindow, Renderer and Actors
        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)
        iren = vtk.vtkRenderWindowInteractor()
        iren.SetRenderWindow(renWin)

        # Add the actors to the renderer, set the background and size
        ren.AddActor(self.axesActor)
        ren.SetBackground(0.1, 0.2, 0.4)
        renWin.SetSize(800, 800)

        ren.ResetCamera()
        cam1 = ren.GetActiveCamera()
        cam1.SetPosition(12.0, 3.0, 150.0)
        cam1.SetFocalPoint(12.0, 12.0, 0.0)
        ren.ResetCameraClippingRange()

        iren.Initialize()
        renWin.Render()
        iren.Start()

visualizer = Visualizer()
visualizer.visualize()




More information about the vtkusers mailing list