# How to let vtkScalarBar showing marks for Text Annotation?

**URL:** https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131
**Category:** Support
**Created:** [January 25, 2019, 12:03pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131 "2019-01-25T12:03:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gabri470](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gabri470/32/58_2.png) [@gabri470](https://discourse.vtk.org/u/gabri470)
#### Post date: [January 25, 2019, 12:03pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131/1 "2019-01-25T12:03:22Z")

</div>

Dear Vtk Experts,

I am trying to add to a vtkScalarbar tick marks in order to link TextAnnotation objects to actual value in colorbar.

I tried in python by using

```
lab.color = (0,0,0)

pp = sc.trait_get('_vtk_obj')['_vtk_obj']

pp.FixedAnnotationLeaderLineColorOn()

```

but this is not helping.

Looking forward to hearing from you.

Gabriele

---

<div class="post-metadata">

### Author: ![embeddedmz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/embeddedmz/32/12_2.png) [@embeddedmz](https://discourse.vtk.org/u/embeddedmz)
#### Post date: [January 30, 2019, 2:39pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131/2 "2019-01-30T14:39:19Z")

</div>

I didn’t understand your question, but I can give you a C++ code I used in the past to display the labels :

```
void MyColorMap::SetupScalarBar()
{
    m_scalarBarActor->SetLookupTable(m_colorManager->GetLookupTable());
    m_scalarBarActor->SetNumberOfLabels(6); // <<=========
    m_scalarBarActor->SetWidth(0.03);
    m_scalarBarActor->SetTitle("........");

    m_scalarBarActor->GetTitleTextProperty()->SetVerticalJustificationToCentered();
    //m_scalarBarActor->GetTitleTextProperty()->SetOrientation(90.);

    m_scalarBarActor->SetPosition(0.95, 0.1);
    m_renderer->AddActor2D(m_scalarBarActor.GetPointer());
} 

```

Otherwise, there’s this VTK class : vtkChartHistogram2D that is, IMHO, a better solution to display a 2D spectrogram (or color map) and that has a builtin scalar bar, I don’t know if a Python wrapping exist for this last (and you will have to use the VTK that is in the gitlab master branch, as recently I fixed nasty bugs in it).

---

<div class="post-metadata">

### Author: ![gabri470](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gabri470/32/58_2.png) [@gabri470](https://discourse.vtk.org/u/gabri470)
#### Post date: [January 30, 2019, 2:46pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131/3 "2019-01-30T14:46:46Z")

</div>

Thanks for you reply.

What I meant was that I’d like to add visible ticks (i.e. a straight line pointing from label to color) to text in scalarColorBar to help correct interpretation of actual values from color bar. There is this LeaderLineColor method that according to the documentation should do what I want to perform, but nothing is displayed. I know that this should be possible ( e.g. Paraview project which uses VTK has those nice color bars)

I hope to have clarified further my question.

---

<div class="post-metadata">

### Author: ![embeddedmz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/embeddedmz/32/12_2.png) [@embeddedmz](https://discourse.vtk.org/u/embeddedmz)
#### Post date: [January 30, 2019, 3:13pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131/4 "2019-01-30T15:13:51Z")

</div>

is there an example in this page : [https://www.paraview.org/Wiki/Beginning\_ParaView](https://www.paraview.org/Wiki/Beginning_ParaView) of what you want to do ?

---

<div class="post-metadata">

### Author: ![gabri470](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gabri470/32/58_2.png) [@gabri470](https://discourse.vtk.org/u/gabri470)
#### Post date: [January 30, 2019, 3:17pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131/5 "2019-01-30T15:17:43Z")

</div>

as you can see in the link provided, color scales have ticks close to their numbers. I am using Pysurfer to display some results (example: [https://pysurfer.github.io/auto\_examples/plot\_fmri\_activation\_volume.html#sphx-glr-auto-examples-plot-fmri-activation-volume-py](https://pysurfer.github.io/auto_examples/plot_fmri_activation_volume.html#sphx-glr-auto-examples-plot-fmri-activation-volume-py)). As you can see in the example of Pysurfer, color bars doesn’t have tick marks for each label/number. The color bar is a vtkscalarColorBar object. It might be that the object used is not suited for what I am trying to achieve .

all the best,

---

<div class="post-metadata">

### Author: ![embeddedmz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/embeddedmz/32/12_2.png) [@embeddedmz](https://discourse.vtk.org/u/embeddedmz)
#### Post date: [January 30, 2019, 3:43pm UTC](https://discourse.vtk.org/t/how-to-let-vtkscalarbar-showing-marks-for-text-annotation/131/6 "2019-01-30T15:43:53Z")

</div>

I take a look to the C++ source code of vtkScalarBarActor (VTK) and vtkPVScalarBarActor (ParaView, which inherits from vtkScalarBarActor), and the feature you want exists only in ParaView, where the ticks marks are created with a vtkActor2D (TickMarksActor), a mapper (vtkPolyDataMapper2D) and a poly data (vtkPolyData).

One with enough free time and will can add this feature in vtkScalarBarActor from vtkPVScalarBarActor (it is not very hard) and creates a Python wrapper.
