# Bar Charts with Large Numbers

**URL:** <https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051>\
**Category:** Development\
**Created:** [September 18, 2025, 4:27pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051 "2025-09-18T16:27:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jessica\_Marquis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jessica_marquis/32/5849_2.png) [@Jessica\_Marquis](https://discourse.vtk.org/u/Jessica_Marquis)\
**Post date:** [September 18, 2025, 4:27pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/1 "2025-09-18T16:27:31Z")

</div>

I am trying to create bar charts and I have found that once you reach large enough numbers for either the x axis (bin ranges) or the y axis (bin sizes), the chart no longer shows up as expected. To test this, you can edit this [bar chart example](https://examples.vtk.org/site/Cxx/Plotting/BarChart/) from vtk so that each of the data\_2008, data\_2009, and data\_2010 arrays hold doubles instead and then multiple each number within the arrays by 10e5. Likewise, you can edit the x axis values by multiplying each number by 10e8. Below I’ve included some images showing the original bar chart vs the chart using the edited values to show what I mean. Can someone explain why this is happening?

_Chart with Original Values:_

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

_Chart with x axis values multiplied by 10e8:_

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/178040cd9585bc073a6312fcb4f95d2b1ab3b33f.png)

_Chart with y axis values multiplied by 10e5:_

 ![image](https://discourse.vtk.org/uploads/default/original/2X/0/059268f65225b489af4e9220c3398d9bb697d680.png)

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [September 18, 2025, 6:09pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/3 "2025-09-18T18:09:02Z")

</div>

I’ve deleted my previous answer, since it was incorrect.

You just need to replace each `vtkIntArray` in the example with `vtkDoubleArray`, and then the plots should come out correctly.

---

<div class="post-metadata">

**Author:** ![Jessica\_Marquis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jessica_marquis/32/5849_2.png) [@Jessica\_Marquis](https://discourse.vtk.org/u/Jessica_Marquis)\
**Post date:** [September 18, 2025, 7:01pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/4 "2025-09-18T19:01:05Z")

</div>

Oh you are correct, that was my bad. That definitely fixes the scaling issues with the y axis. The x axis with the bin ranges still looks pretty screwed up straight off though. The first image is what I get by default when I run the original example with the vtkDoubleArray and the x values multiplied by 10e8. But when I start zooming in a little with the mouse wheel I eventually get the second image

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

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

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [September 18, 2025, 8:11pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/5 "2025-09-18T20:11:40Z")

</div>

It looks like it’s rendering bars on top of each other. That’s why there are black lines, each black horizontal line is the top of one of the shorter bars that was rendered after a taller bar that was rendered before. Not sure why it ended up yellow instead of orange or green, but that must have something to do with the order of the rendering.

So the question is, why is it rendering multiple bars at the same position?

---

<div class="post-metadata">

**Author:** ![Jessica\_Marquis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jessica_marquis/32/5849_2.png) [@Jessica\_Marquis](https://discourse.vtk.org/u/Jessica_Marquis)\
**Post date:** [September 19, 2025, 12:11pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/6 "2025-09-19T12:11:12Z")

</div>

Yes that is the main problem/question I was looking to get answered. Is there a particular threshold at which this happens? I could of course just use indexes to position the bars along the x axis and use the actual values just as the labels but I am wondering if there is a reliable way to tell when I would have to do this or why I should even have to in the first place.

---

<div class="post-metadata">

**Author:** ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)\
**Post date:** [September 21, 2025, 3:38am UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/7 "2025-09-21T03:38:54Z")

</div>

Wouldn’t it just be easier to change the units on each axis. e.g. MW, GPa etc

---

<div class="post-metadata">

**Author:** ![Michael\_Jackson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael_jackson/32/61_2.png) [@Michael\_Jackson](https://discourse.vtk.org/u/Michael_Jackson)\
**Post date:** [September 22, 2025, 5:22pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/8 "2025-09-22T17:22:56Z")

</div>

This is user data coming into our application and so we are at the whim of the user.

This is clearly a bug in the VTK Charting codes that I am sure the VTK devs will work out. If it is not a bug then the API for the charting would need to be updated to reflect the proper magnitudes are data that can be used with the VtkCharts.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [September 23, 2025, 3:12pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/9 "2025-09-23T15:12:09Z")

</div>

Just to add a bit more information, this bug appears with bar charts but not line charts, even for huge values like 1e300 that are close to the limit of what a double-precision float can represent. That narrows down what code might be responsible.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [September 24, 2025, 4:27am UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/10 "2025-09-24T04:27:40Z")

</div>

I’ve reported this in the VTK bugtracker:  
[https://gitlab.kitware.com/vtk/vtk/-/issues/19791](https://gitlab.kitware.com/vtk/vtk/-/issues/19791)

The large values trigger an automatic rescaling of the plot, which is supposed to ensure that it can be drawn accurately with 32-bit floats (which is the data type that `vtkPlot` uses internally for drawing). However, the rescaling seems to be incorrectly implemented for `vtkPlotBar`, causing the results that you’ve shown above.

---

<div class="post-metadata">

**Author:** ![Jessica\_Marquis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jessica_marquis/32/5849_2.png) [@Jessica\_Marquis](https://discourse.vtk.org/u/Jessica_Marquis)\
**Post date:** [September 24, 2025, 1:04pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/11 "2025-09-24T13:04:18Z")

</div>

Thank you very much for looking into this!

---

<div class="post-metadata">

**Author:** ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)\
**Post date:** [October 31, 2025, 3:50pm UTC](https://discourse.vtk.org/t/bar-charts-with-large-numbers/16051/12 "2025-10-31T15:50:42Z")

</div>

Thank you for reporting this @Jessica_Marquis.  
This issue has been fixed in [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/12498](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/12498)
