# How to set the fixed width/height for vtkScalarBarActor?

**URL:** https://discourse.vtk.org/t/how-to-set-the-fixed-width-height-for-vtkscalarbaractor/9676
**Category:** Support
**Created:** [October 25, 2022, 1:10pm UTC](https://discourse.vtk.org/t/how-to-set-the-fixed-width-height-for-vtkscalarbaractor/9676 "2022-10-25T13:10:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [October 25, 2022, 1:10pm UTC](https://discourse.vtk.org/t/how-to-set-the-fixed-width-height-for-vtkscalarbaractor/9676/1 "2022-10-25T13:10:54Z")

</div>

I am using `vtkScalarBarActor` in my application. However, the width/height of `vtkScalarBarActor` is changing when the render window is changed.

For example:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/561cfef5115646af30cf08288b21db3c1417cf8e.png)

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/fc692ad64329686eaea97cb1d16635bcbba7856d.png)

For example, the width of `vtkScalarBarActor` of second figure is much larger than that of first figure. And the large width of `vtkScalarBarActor` in second figure is ugly.

Is there any method to set fixed width for `vtkScalarBarActor`? I hope it is not changed when the window size is changed.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [October 26, 2022, 7:15pm UTC](https://discourse.vtk.org/t/how-to-set-the-fixed-width-height-for-vtkscalarbaractor/9676/2 "2022-10-26T19:15:20Z")

</div>

Hi,

The placement of those 2D widgets is a proportion of the viewport, so it expectedly changes as the latter’s aspect ratio changes. To have a fixed apparent width regardless of viewport aspect ratio, you have to change the scalar bar’s relative width on each viewport resize event.

Alternativelly, you can try `SetMaximum[Width|Height]InPixels(value)` to impose limits to avoid such undesirable effects. Calling `AnnotationTextScalingOff()` will switch of text resize so you won’t get huge characters in your scalar bar.

There are several other methods available in `vtkScalarBarActor` to control its appearance: [https://vtk.org/doc/nightly/html/classvtkScalarBarActor.html](https://vtk.org/doc/nightly/html/classvtkScalarBarActor.html) .

take care,

Paulo

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [October 27, 2022, 9:42am UTC](https://discourse.vtk.org/t/how-to-set-the-fixed-width-height-for-vtkscalarbaractor/9676/3 "2022-10-27T09:42:52Z")

</div>

@Paulo_Carvalho Many thanks for such kindly reply.
