Jump to content

How to auto-add error bar via ironpython on a multi-column Y-axis


Jia Wei Chen

Recommended Posts

Does anybody knows how to add error bar via ironypython on a multi-column Y-axis

I can print out all columns in the Y-axis. In theory, this should work. However, when I ran my code in Spotfire the same column of error bar apply to all columns in the same Y-axis.

For example, Y-axis has column A,B, C, D,E.

I need separate error bar for A, B,C,D,E. The code below apply error bar of A to column A,B,C,D,E.

 

for column_name in column_names:

#print(visual.Title)

#print(column_name)

#Set the "Upper error:" expression:

chart.YAxis.ErrorBars.UpperExpression = "StdDev("+column_name+")"

#chart.YAxis.ErrorBars.UpperExpression = ""

print(chart.YAxis.ErrorBars.UpperExpression)

#Set the "Lower error:" expression:

chart.YAxis.ErrorBars.LowerExpression = "StdDev("+column_name+")"

#chart.YAxis.ErrorBars.LowerExpression = ""

print(chart.YAxis.ErrorBars.LowerExpression)

 

 

I have look up the API document and tried the indexed enabled property and category Key. My columns are just Avg(A), Avg(B) and Avg© ect. There are no "As" in my y-axis column and I would like to avoid using the "As" in the actual Y-axis because it is not needed for the end users.

The "for loop", loops through all columns in the Y-axis in each visualization and each page to find columns in the Y-axis.

 

for column_name in column_names:

#print(visual.Title)

#print(column_name)

#Set the "Upper error:" expression:

#print(chart.YAxis.Expression)

CategoryKey colKey = new CategoryKey(column_name)

chart.YAxis.ErrorBars.IndexedEnabled[colKey]=True

chart.YAxis.ErrorBars.IndexedUpperExpression[colKey] = "StdDev("+column_name+")"

chart.YAxis.ErrorBars.IndexedLowerExpression[colKey] = "StdDev("+column_name+")"

 

Any help are appeciated!

 

This is the API document example.

 

The indexed enabled property is used instead of theEnabledproperty when there are multiple measures on theScaleAxis(e.g. multiple columns on the Y axis in a line chart).

lineChart.YAxis.Expression = "Avg([sales]) as MySales, Avg([Profit]) as MyProfit";

CategoryKey salesKey = new CategoryKey("MySales");

lineChart.YAxis.ErrorBars.IndexedEnabled[salesKey] = true;

lineChart.YAxis.ErrorBars.IndexedUpperExpression[salesKey] = "StdErr(Sales)";

lineChart.YAxis.ErrorBars.IndexedLowerExpression[salesKey] = "StdErr(Sales)";

CategoryKey profitKey = new CategoryKey("MyProfit");

lineChart.YAxis.ErrorBars.IndexedEnabled[profitKey] = true;

lineChart.YAxis.ErrorBars.IndexedUpperExpression[profitKey] = "StdErr(Profit)";

lineChart.YAxis.ErrorBars.IndexedLowerExpression[profitKey] = "StdErr(Profit)";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...