# Is there a way to fix the number of labels on the Axes Grid?

**URL:** https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142
**Category:** ParaView Support
**Tags:** python
**Created:** [May 23, 2023, 9:06pm UTC](https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142 "2023-05-23T21:06:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mclarsen](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@mclarsen](https://discourse.paraview.org/u/mclarsen)
#### Post date: [May 23, 2023, 9:06pm UTC](https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142/1 "2023-05-23T21:06:21Z")

</div>

We are running into a performance issue displaying the axes grids. The default function increases the number of labels depending on the zoom factor. I assume the code is trying to keep the labels equally spaced in screen space, but the issue is that the number of labels is unbounded. I suspect the cpu code keeps generating more and more labels, even though only a few can be seen, which slows the framerate below 1 FPS.

I can’t seem to find a property to set in python that fixes the number of ticks/labels, and creating custom ticks is not really an option either since the data ranges are always changing depending on what is visible. Anyone have a suggestion to fix the performance?

---

<div class="post-metadata">

### Author: ![mclarsen](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@mclarsen](https://discourse.paraview.org/u/mclarsen)
#### Post date: [May 23, 2023, 9:42pm UTC](https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142/2 "2023-05-23T21:42:41Z")

</div>

related: [Axis labels are out of control](https://discourse.paraview.org/t/axis-labels-are-out-of-control/705)

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [May 24, 2023, 1:07am UTC](https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142/3 "2023-05-24T01:07:32Z")

</div>

Thanks for the report. Yes, this is a bug (and once I replicated it, a bad one). Wrote it up here: [https://gitlab.kitware.com/paraview/paraview/-/issues/22153](https://gitlab.kitware.com/paraview/paraview/-/issues/22153). Scheduled for this fall, not to slip past next spring.

---

<div class="post-metadata">

### Author: ![mclarsen](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@mclarsen](https://discourse.paraview.org/u/mclarsen)
#### Post date: [May 24, 2023, 5:40pm UTC](https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142/4 "2023-05-24T17:40:36Z")

</div>

Alan, thanks for escalating the priority. I am going to look into workarounds inside paraview. I have a couple ideas, but I need to get things building to test them.

---

<div class="post-metadata">

### Author: ![mclarsen](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@mclarsen](https://discourse.paraview.org/u/mclarsen)
#### Post date: [May 24, 2023, 10:46pm UTC](https://discourse.paraview.org/t/is-there-a-way-to-fix-the-number-of-labels-on-the-axes-grid/12142/5 "2023-05-24T22:46:26Z")

</div>

For what its worth, this is how I solved the issue:

```auto
diff --git a/Charts/Core/vtkAxis.cxx b/Charts/Core/vtkAxis.cxx
index d2c86ee8e9..c23a3390c2 100644
--- a/Charts/Core/vtkAxis.cxx
+++ b/Charts/Core/vtkAxis.cxx
@@ -1267,6 +1267,13 @@ void vtkAxis::GenerateTickLabels(double min, double max)
     {
       double range = mult > 0.0 ? max - min : min - max;
       n = vtkContext2D::FloatToInt(range / this->TickInterval);
+ constexpr int maxTicks = 21;
+ // We need to bound the total number of ticks.
+ if(n > maxTicks) 
+ {
+ this->TickInterval = range / double(maxTicks);
+ n = vtkContext2D::FloatToInt(range / this->TickInterval);
+ }

```
