# Scale bars in vtk python

**URL:** https://discourse.vtk.org/t/scale-bars-in-vtk-python/4094
**Category:** Support
**Created:** [August 29, 2020, 7:19am UTC](https://discourse.vtk.org/t/scale-bars-in-vtk-python/4094 "2020-08-29T07:19:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Olga\_Ridzel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/olga_ridzel/32/2086_2.png) [@Olga\_Ridzel](https://discourse.vtk.org/u/Olga_Ridzel)
#### Post date: [August 29, 2020, 7:19am UTC](https://discourse.vtk.org/t/scale-bars-in-vtk-python/4094/1 "2020-08-29T07:19:49Z")

</div>

Dear VTK team,

I’m looking for a way to add scale bars to the render window both in python and js. An example picture is attached.

 ![Capture.PNG](https://discourse.vtk.org/uploads/default/original/2X/b/b6b004243ff31f8aac019a07fcfcfd29ee865b49.jpeg)  
I used vtkLineSource and vtkVectorText but depending on the image size I render this doesn’t work sometimes, so I need some universal solution so that the scale bar line and text always look ok.

Could you please advise something concerning this problem?

Best wishes,  
Olga.

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [August 29, 2020, 11:07am UTC](https://discourse.vtk.org/t/scale-bars-in-vtk-python/4094/2 "2020-08-29T11:07:55Z")

</div>

I only know of `vtkLegendScaleActor`, but I guess because of perspective it might be a bit misleading, eg.

```python
from vedo import *
c = Cylinder()
x0,x1,y0,y1,z0,z1 = c.bounds()
r = Ruler([x1+.1,y0,z0], [x1+.1,y1,z0], units='\mum')
show(c, r, axes=13) # 13=vtkLegendScaleActor

```

![Screenshot from 2020-08-29 12-53-10](https://discourse.vtk.org/uploads/default/original/2X/2/21595f9a90e3477c6b6bb15e18ead3d4e92a7959.png)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 29, 2020, 3:44pm UTC](https://discourse.vtk.org/t/scale-bars-in-vtk-python/4094/3 "2020-08-29T15:44:16Z")

</div>

I would not even allow displaying a ruler if you use perspective projection, but should work well for parallel projection. You can even display it as a 2D actor - see how it is done in C++ [here](https://github.com/Slicer/Slicer/blob/47deb76d7556e40de4e25e585c4b24a63a153da5/Libs/MRML/DisplayableManager/vtkMRMLRulerDisplayableManager.cxx).

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [August 29, 2020, 4:13pm UTC](https://discourse.vtk.org/t/scale-bars-in-vtk-python/4094/4 "2020-08-29T16:13:22Z")

</div>

…true, it doesn’t make much sense. Indeed it works well in parallel projection

![image](https://discourse.vtk.org/uploads/default/original/2X/8/89012e6fb119436bd0ac6f966dca68ffe1865be0.png)
