# Bug in vtkAxisActor2D::SetTitle()?

**URL:** https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869
**Category:** Support
**Created:** [November 18, 2022, 12:09am UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869 "2022-11-18T00:09:32Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [November 18, 2022, 12:09am UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/1 "2022-11-18T00:09:32Z")

</div>

I’m running VTK-9.2 for C++.  
My code creates a vtkCubeAxesActor2D, and sets data range and title for x, y, and z axes. The ranges are displayed properly, but titles display as ‘X’, ‘Y’, and ‘Z’ (defaults?) instead of ‘Longitude’, ‘Latitude’, and ‘Depth’. Here is the code:

```auto
  xUnits = "Longitude";
  yUnits = "Latitude";
  zUnits = "Depth";
  
  qDebug() << "set x-axis label to " << xUnits;
  axesActor->GetXAxisActor2D()->SetTitle(xUnits);
  qDebug() << "set y-axis label to " << yUnits;  
  axesActor->GetYAxisActor2D()->SetTitle(yUnits);
  qDebug() << "set z-axis label to " << zUnits;    
  axesActor->GetZAxisActor2D()->SetTitle(zUnits);

  qDebug() << "actual x-axis label now is " <<
    axesActor->GetXAxisActor2D()->GetTitle();

```

The output is:

```auto
set x-axis label to Longitude
set y-axis label to Latitude
set z-axis label to Depth
actual x-axis label now is Longitude

```

But the display shows axes labeled as “X”, “Y”, and “Z”.  
Anyone know what I am doing wrong? Or is there a bug in [vtkAxisActor2D::SetTitle()](https://vtk.org/doc/nightly/html/classvtkAxisActor2D.html)?  
Thanks!

---

<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: [November 24, 2022, 9:49pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/2 "2022-11-24T21:49:53Z")

</div>

Hello,

Try calling `RenderOpaqueGeometry( vtkViewport* )` on each of your `vtkAxisActor2D` objects **after** setting the title strings. After studying the source code of `vtkAxisActor2D` it seems to me that changing the title doesn’t trigger an update.

take care,

Paulo

---

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [November 25, 2022, 5:27pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/3 "2022-11-25T17:27:18Z")

</div>

Calling RenderOpaqueGeometry() didn’t fix the problem, but I might be using that function incorrectly. What do I pass as an argument to RenderOpaqueGeometry() in this case? My pipeline includes a single vtkRenderer instance, and I am passing that as the argument for each vtkAxisActor2D.  
Thanks!

---

<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: [November 25, 2022, 9:18pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/4 "2022-11-25T21:18:29Z")

</div>

Try passing your `vtkRenderer`. `vtkRenderer` is a `vtkViewport` subclass.

---

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [November 25, 2022, 9:50pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/5 "2022-11-25T21:50:44Z")

</div>

Yes I am passing my vtkRenderer instance but the problem persists.

---

<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: [November 26, 2022, 9:11pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/6 "2022-11-26T21:11:56Z")

</div>

Try calling the `Set[X|Y|Z]Label()` methods of the `vtkCubeAxesActor2D` itself.

---

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [November 28, 2022, 5:39pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/7 "2022-11-28T17:39:01Z")

</div>

Yes, calling vtkCubeAxesActor2D::Set[X][Y][Z]Label() methods works, with no need to force an update. Thanks!  
So is there a bug in vtkAxisActor2D::SetTitle()?

---

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [November 29, 2022, 1:05am UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/8 "2022-11-29T01:05:33Z")

</div>

My tests also seem to indicate that vtkAxisActor2D::SetRange(min, max) also has no effect. Can you verify? Thanks!

---

<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: [November 29, 2022, 5:58pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/9 "2022-11-29T17:58:41Z")

</div>

Possibly, but that’s not the way supposed to change the axes titles, so I wouldn’t call it a bug.

---

<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: [November 29, 2022, 5:59pm UTC](https://discourse.vtk.org/t/bug-in-vtkaxisactor2d-settitle/9869/10 "2022-11-29T17:59:26Z")

</div>

Please, start another thread for that. Thanks.
