[vtkusers] Why Axis Labels (X,Y,Z) do not show (Axes.py)?
Kang Zhao
zhaokang.cn at gmail.com
Sun Jul 27 20:53:23 EDT 2014
Hello,
When I ran the attached Python script, the axis lables (X,Y,Z) didn't
show up. I also tried playing with
axes.GetXAxisCaptionActor2D().GetCaptionTextProperty.SetColor(1,0,0) and
SetXAxisLabelText(), but no success.
PS, the script could be found at:
http://www.cmake.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Axes.
Could anyone help to share some clue?
My environment:
OS: Windows 7 (64-bit)
Python: 2.7.7 (32 bit)
wxPython: wxPython2.8-win32-unicode-2.8.12.1-py27.exe
VTK: vtkpython-6.1.0-Windows-32bit.exe
Thanks for your help in advance.
Kang
-------------- next part --------------
import vtk
#create a Sphere
sphereSource = vtk.vtkSphereSource()
sphereSource.SetCenter(0.0, 0.0, 0.0)
sphereSource.SetRadius(0.5)
#create a mapper
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInputConnection(sphereSource.GetOutputPort())
#create an actor
sphereActor = vtk.vtkActor()
sphereActor.SetMapper(sphereMapper)
#a renderer and render window
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
#an interactor
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
#add the actors to the scene
renderer.AddActor(sphereActor)
renderer.SetBackground(.1,.2,.3) # Background dark blue
transform = vtk.vtkTransform()
transform.Translate(1.0, 0.0, 0.0)
axes = vtk.vtkAxesActor()
# The axes are positioned with a user transform
axes.SetUserTransform(transform)
# properties of the axes labels can be set as follows
# this sets the x axis label to red
# axes->GetXAxisCaptionActor2D()->GetCaptionTextProperty()->SetColor(1,0,0);
# the actual text of the axis label can be changed:
# axes->SetXAxisLabelText("test");
renderer.AddActor(axes)
renderer.ResetCamera()
renderWindow.Render()
# begin mouse interaction
renderWindowInteractor.Start()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Axes.png
Type: image/png
Size: 39038 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140728/ce00c782/attachment.png>
More information about the vtkusers
mailing list