# Custom axis values (vtkMRMLChartNode)

**URL:** <https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116>\
**Category:** Support\
**Tags:** plots\
**Created:** [February 19, 2018, 2:35pm UTC](https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116 "2018-02-19T14:35:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmarcano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fmarcano/32/222_2.png) [@fmarcano](https://discourse.slicer.org/u/fmarcano)\
**Post date:** [February 19, 2018, 2:35pm UTC](https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116/1 "2018-02-19T14:35:42Z")

</div>

From python, is it possible to reverse the order of X axis (vtkMRMLChartNode, vtkMRMLChartViewNode object nodes) on a displayed chart? For example:  
original X axis view: … -3 -2 -1 0 1 2 3 …  
required X axis view: … 3 2 1 0 -1 -2 -3 …

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 21, 2018, 3:37am UTC](https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116/2 "2018-02-21T03:37:56Z")

</div>

We don’t develop the old JavaScript-based plotting infrastructure anymore, but replacing it with VTK-based plots. It is faster and allows plotting directly from table nodes, and offers much more customization features.

I’ve just implemented today custom axis range, so you can have +3 on the left and -3 on the right side. This feature will be available in Slicer nightly version that you download tomorrow or later. See information and usage examples here:

- [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots)
- [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create\_histogram\_plot\_of\_a\_volume](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create_histogram_plot_of_a_volume)

---

<div class="post-metadata">

**Author:** ![fmarcano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fmarcano/32/222_2.png) [@fmarcano](https://discourse.slicer.org/u/fmarcano)\
**Post date:** [February 21, 2018, 2:44pm UTC](https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116/3 "2018-02-21T14:44:41Z")

</div>

Thank you very much. I’ll follow your advice then I’ll tell you how it went.

---

<div class="post-metadata">

**Author:** ![fmarcano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fmarcano/32/222_2.png) [@fmarcano](https://discourse.slicer.org/u/fmarcano)\
**Post date:** [April 6, 2018, 9:06am UTC](https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116/4 "2018-04-06T09:06:20Z")

</div>

I’ve seen the plot example in [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots), and neither there nor my own code examples, X axis values are shown properly.

For example, in the Nightly developer plot code figure, the table shows X values going from 0 to 7.5 in steps of 0.11 aprox., but in the chart points have a X value (abcise) having a step of 1. This means, i.e, point (0.110294, 0.993924) becomes (1,0.993924) , which leads to misinterpretation of data.

Am I missing any function call in the code to show exact X axis values?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 6, 2018, 1:47pm UTC](https://discourse.slicer.org/t/custom-axis-values-vtkmrmlchartnode/2116/5 "2018-04-06T13:47:41Z")

</div>

Thanks for the feedback. I see that the example uses the default Line plot type, which uses sample index as X coordinates. You need to set the plot type using `SetPlotType` method to `slicer.vtkMRMLPlotSeriesNode.PlotTypeScatter` to see a scatter plot. I’ve updated the example code and screenshot.
