Plotting help? SetXColumnName ignored

I am trying to work with slicer’s plotting nodes to use in an extension and I’m running into some issues

The main one is that calling SetXColumnName('X') on a vtkMRMLPlotSeriesNode seems to be ignored, and the x axis is always just the row index of the table.

here is the script i’ve been testing with.

I would have expected the x axis to run from 1000-1100 as opposed to 0-100. calling SetYColumnName auto updates the Y values so the table seems correct.

Can you also point me to the api that shows how to turn on/set the x and y axis labels?

Thanks!
Luke

“X axis column” is only used by scatter plot types, such as “scatter” or “scatter bar”. If you just want to display labels for values in “Y axis column” then you can choose any string column as “Labels column”. To get familiar with how things work, you can get started with using Plots module GUI.

If you just need to plot a numpy array, you can use the slicer.util.plot convenience function. For example:

values = np.random.uniform(5, 25, [10,2])
chart = slicer.util.plot(values, xColumnIndex=0, columnNames=['x' ,'y'], title='My chart')

See more examples here.