vtkScalarBarWidget resizing

Hello! I want to resize, change position and change text size of my vtkScalarBarWidget but my code not works. Any tips why? I using QVTKRenderWindowInteractor btw.

self.scalar_bar = vtkScalarBarActor()
self.scalar_bar_widget = vtkScalarBarWidget()
self.scalar_bar_widget.SetInteractor(self.iren)
self.scalar_bar_widget.SetScalarBarActor(self.scalar_bar)
self.scalar_bar_widget.On()
self.scalar_bar.SetLookupTable(lut)
self.scalar_bar.SetTitle(title)
self.scalar_bar.SetNumberOfLabels(10)
text_property = self.scalar_bar.GetLabelTextProperty()
text_property.SetFontSize(12)

self.scalar_bar.VisibilityOn()

Hello,

What did you do to try to change the position of the widget?

best,

PC

I already resolve this issue with this code:

        self.scalar_bar.UnconstrainedFontSizeOn()
        title_property = self.scalar_bar.GetTitleTextProperty()
        title_property.SetFontSize(20)
        title_property.SetVerticalJustificationToBottom()

        text_property = self.scalar_bar.GetLabelTextProperty()
        text_property.SetFontSize(20)
        self.scalar_bar.SetNumberOfLabels(7)
        self.scalar_bar.SetMaximumWidthInPixels(150)
        self.scalar_bar.SetMaximumHeightInPixels(700)

        self.scalar_bar_widget.SetScalarBarActor(self.scalar_bar)
        scalar_bar_representation = self.scalar_bar_widget.GetRepresentation()

        scalar_bar_representation.SetPosition(0.1, 0.2)
        scalar_bar_representation.SetPosition2(0.08, 0.6)

1 Like