I primarily use VTK in 3D Slicer (cc @lassoan) and noticed a difference in how my vtkAxisActor2D code works upon switching a version of Slicer that was using VTK 9.2 versus more recent VTK 9.4 and 9.5 versions.
My initial suspicion is that the rework completed in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10910 has introduced an unexpected change in result. cc: @nicolas.vuaille
VTK 9.2:
VTK 9.4, 9.5 (note that the label for “50” is located at the very bottom of the window rather than at the top major tick):
Code snippet used to generate the above results:
import vtk
# Create a renderer and render window
render_window = vtk.vtkRenderWindow()
render_window.SetSize(400, 600)
renderer = vtk.vtkRenderer()
render_window.AddRenderer(renderer)
renderer.SetBackground(0.1, 0.1, 0.1)
# Create render window interactor
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)
# Create and configure the axis actor
axis = vtk.vtkAxisActor2D()
axis.SetRange(0, 50)
axis.SetNumberOfLabels(6) # 0, 10, 20, 30, 40, 50
axis.SetLabelFormat("%g")
axis.LabelVisibilityOn()
axis.TitleVisibilityOff()
axis.SetFontFactor(1.0)
axis.SetLabelFactor(1.0)
axis.GetLabelTextProperty().SetColor(1, 1, 1)
axis.GetLabelTextProperty().SetFontSize(16)
axis.SetTickLength(12)
axis.SetMinorTickLength(6)
axis.SetNumberOfMinorTicks(4)
axis.AdjustLabelsOff()
axis.RulerModeOff()
# Set vertical orientation: 0 at bottom, 50 at top
x_pos = 0
axis.SetPosition(x_pos, 0.1) # bottom
axis.SetPosition2(x_pos, 0.9) # top
# Add to renderer
renderer.AddViewProp(axis)
# Render
render_window.Render()
interactor.Initialize()
interactor.Start()