Search code examples
ironpythonspotfire

Multiple Y columns scatter plot color by with IronPython


I create scatter plot with IronPython (2.7.7) (Spotfire 7.11): I have many columns on Y axis. Excerpt from the code below:

plot = page.Visuals.AddNew[ScatterPlot]()
plot.Data.DataTableReference = dataTable
plot.XAxis.Expression = "<minSize>"
plotCols = getPlotCols(dataTable)
plot.MarkerSize = 2.0
plot.ShapeAxis.DefaultShape = MarkerShape(MarkerType.Circle)
plot.YAxis.Expression = plotCols

The scatter-plot is created, but I get the following error message:

With multiple columns on y axis, "(Column Names)" has to be selected on X-axis or used to color by ...

enter image description here

When I click on the side panel 'Color by:' and select (Column Names), I get exactly the desired output. I want to achieve this output using the IronPython script, without additional clicking.

I have tried the following:

plot.ColorAxis.Expression = plotCols #same format as YAxis "[colname1],[colname2], ...etc"

I have tried many permutations of how to write (Column Names) to ColorAxis.Expression like "(Column Names)", "[(Column Names)]", ... all without the effect.

I have faith that this must be possible. Can you help?


Solution

  • If someone else is interested in answer, I found the solution:

    plot.ColorAxis.Expression = "<[Axis.Default.Names]>"
    

    This was the line needed. it's strange that, even now when I know solution, I still can't find it anywhere. So let it be documented here.