Custom axis values (vtkMRMLChartNode)

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 …

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:

2 Likes

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

I’ve seen the plot example in 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?

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.