[Paraview] Python: How to change the location and size of orientation axes?

Liang Wang frank0734 at gmail.com
Sat Apr 8 19:46:40 EDT 2017


I figured out a way by using the vtkAxesActor class directly.

An example script:

from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

renderView1 = GetActiveViewOrCreate('RenderView')

sphere1 = Sphere()
sphere1.Radius = 1.0
sphere1Display = Show(sphere1, renderView1)
sphere1Display.SetRepresentationType('Outline')

import vtk
renderer = renderView1.GetRenderer()
axes = vtk.vtkAxesActor()

#axes.SetAxisLabels(0) # 0/1 to turn off/on axis labels

transform = vtk.vtkTransform()
transform.Translate(-1.0, -1.0, -1.0)
transform.Scale(0.75, 0.75, 0.75)
axes.SetUserTransform(transform)

tprop = vtk.vtkTextProperty()
#tprop.SetFontSize(6) # seems to be overriden by vtkCaptionActor2D
tprop.SetBold(1)
tprop.SetItalic(0)
tprop.SetColor(1.0, 1.0, 1.0)
tprop.SetOpacity(1.0)
tprop.SetFontFamilyToTimes()

for label in [
        axes.GetXAxisCaptionActor2D(),
        axes.GetYAxisCaptionActor2D(),
        axes.GetZAxisCaptionActor2D(),
        ]:
    # set Positoin2
    label.SetWidth(label.GetWidth() * 0.5)
    label.SetHeight(label.GetHeight() * 0.5)
    label.SetCaptionTextProperty(tprop)

renderer.AddActor(axes)

Interact()


On Sat, Apr 8, 2017 at 4:08 PM, Liang Wang <frank0734 at gmail.com> wrote:

> From http://public.kitware.com/pipermail/paraview/2010-July/018081.html
> it was not possible back then to change the size of orientation axes.
>
> Is it possible now, hopefully through Python, too?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170408/f8c5740a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot_2017-04-08_19-45-18.png
Type: image/png
Size: 9733 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170408/f8c5740a/attachment.png>


More information about the ParaView mailing list