Value Axis

These IronPython scripts below show how to modify any of the Bar Chart visualization settings found on the Value Axis tab of the Bar Chart Properties dialog box in the Spotfire user interface.

The bar chart value axis tab layout in the Spotfire user interface changes quite a bit depending on whether the “One axis with a single scale” or “Multiple scales” option is selected. To reflect this, I’ve split the IronPython scripts for this tab into two sections, one for each scenario:

Note

In each of the scripts below, it is assumed that the MyVis variable references the targeted visualization. See here for more information about referencing visualizations.

Change Value Axis Options - Single Scale:

This IronPython script shows how to change the following options, roughly in order as they appear on the value axis tab when the “One axis with a single scale” option is selected.

  1. Change the axis expression
  2. Use one axis with a single scale
  3. Set the range min and max
  4. Include origin
  5. Show zoom slider
  6. Show gridlines
  7. Reverse scale
  8. Show (or hide) scale labels
  9. Show labels horizontally or vertically
  10. Set max number of labels
Note

If you aren't sure how to write a specific custom expression correctly from scratch, start by building the expression interactively using the Spotfire user interface. Once your custom expression is working correctly, right-click on the custom expression input box selector(s) and choose Custom Expression. You can then copy the expression shown into your IronPython script.

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()

# 1. Change the axis expression
myVis.YAxis.Expression = "<[My Column]>"

# 2. Use one axis with a single scale
myVis.YAxis.IndividualScaling = False

# 3. Set the range min and max
# Enter as AxisRange([minimum], [maximum]) to set the range
myVis.YAxis.Range = AxisRange(50, 250)
# OR
# Enter None keyword to set either end of the range back to "Automatic"
myVis.YAxis.Range = AxisRange(None, None)

# 4. Include origin
myVis.YAxis.IncludeZeroInAutoZoom = True

# 5. Show zoom slider
myVis.YAxis.ManualZoom = True

# 6. Show gridlines
myVis.YAxis.Scale.ShowGridlines = True

# 7. Reverse scale
myVis.YAxis.Reversed = True

# 8. Show (or hide) scale labels
myVis.YAxis.Scale.ShowLabels = True

# 9. Show labels horizontally or vertically
myVis.YAxis.Scale.LabelOrientation = LabelOrientation.Horizontal
# OR
myVis.YAxis.Scale.LabelOrientation = LabelOrientation.Vertical

# 10. Set max number of labels
# To check the "Max number of labels" checkbox and set the number:
myVis.YAxis.Scale.LabelLayout = ScaleLabelLayout.MaximumNumberOfTicks
myVis.YAxis.Scale.MaximumNumberOfTicks = 15
# OR
# To un-check the "Max number of labels" checkbox and ignore the number:
myVis.YAxis.Scale.LabelLayout = ScaleLabelLayout.Automatic

Change Value Axis Options - Multiple Scales:

This IronPython script shows how to change the following options, roughly in order as they appear on the value axis tab when the “Multiple scales” option is selected.

  1. Change the axis expression (multiple columns)
  2. Use multiple scales
  3. Use individual scales for each color or for each trellis panel
  4. Show zoom slider
  5. Show gridlines
  6. Set the range min and max (per scale)
  7. Include origin (per scale)
  8. Position scales to the left or right axis (per scale)
  9. Reverse scale (per scale)
  10. Show (or hide) scale labels
  11. Show labels horizontally or vertically
  12. Set max number of labels
Note

If you aren't sure how to write a specific custom expression correctly from scratch, start by building the expression interactively using the Spotfire user interface. Once your custom expression is working correctly, right-click on the custom expression input box selector(s) and choose Custom Expression. You can then copy the expression shown into your IronPython script.

warning

In step 6, 7, 8, and 9 below, where an indexed axis is being referenced, the square brackets ([]) around the column names must be removed. In other words, Sum([Column1]) must be referenced as Sum(Column1). To verify the correct references for more complicated custom expressions, you can also check the text in the dropdown under the “Individual scale settings” section of the Value Axis tab.

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()

# 1. Change the axis expression (multiple columns)
myVis.YAxis.Expression = "Sum([Column1]), Sum([Column2]), Avg([Column3])"

# 2. Use multiple scales
myVis.YAxis.IndividualScaling = True

# 3. Use individual scales for each color or for each trellis panel
# "For each color" option:
myVis.YAxis.IndividualScalingMode = IndividualScalingMode.Color
# OR
# "For each trellis panel" option:
myVis.YAxis.IndividualScalingMode = IndividualScalingMode.Trellis

# 4. Show zoom slider
myVis.YAxis.ManualZoom = True

# 5. Show gridlines
myVis.YAxis.Scale.ShowGridlines = True

# 6. Set the range min and max (per scale)
# Indicate the targeted scale by its expression (as in user interface dropdown)
# Enter as AxisRange([minimum], [maximum]) to set the ranges
myVis.YAxis.IndexedRange["Sum(Column1)"] = AxisRange(50, 250)
myVis.YAxis.IndexedRange["Sum(Column2)"] = AxisRange(-100, 150)
# OR
# Enter None keyword to set either end of the ranges back to "Automatic"
myVis.YAxis.IndexedRange["Sum(Column1)"] = AxisRange(None, None)

# 7. Include origin (per scale)
# Indicate the targeted scale by its expression (as in user interface dropdown)
myVis.YAxis.IndexedIncludeZeroInAutoZoom["Sum(Column1)"] = True
myVis.YAxis.IndexedIncludeZeroInAutoZoom["Sum(Column2)"] = False

# 8. Position scales to the left or right axis (per scale)
# Indicate the targeted scale by its expression (as in user interface dropdown)
# "Left value axis" option:
myVis.YAxis.Scale.IndexedDock["Sum(Column1)"] = ScaleDock.Near
# OR
# "Right value axis" option:
myVis.YAxis.Scale.IndexedDock["Sum(Column2)"] = ScaleDock.Far 

# 9. Reverse scale (per scale)
# Indicate the targeted scale by its expression (as in user interface dropdown)
myVis.YAxis.IndexedReversed["Sum(Column1)"] = True
myVis.YAxis.IndexedReversed["Sum(Column2)"] = False

# 10. Show (or hide) scale labels
myVis.YAxis.Scale.ShowLabels = True

# 11. Show labels horizontally or vertically
myVis.YAxis.Scale.LabelOrientation = LabelOrientation.Horizontal
# OR
myVis.YAxis.Scale.LabelOrientation = LabelOrientation.Vertical

# 12. Set max number of labels
# To check the "Max number of labels" checkbox and set the number:
myVis.YAxis.Scale.LabelLayout = ScaleLabelLayout.MaximumNumberOfTicks
myVis.YAxis.Scale.MaximumNumberOfTicks = 15
# OR
# To un-check the "Max number of labels" checkbox and ignore the number:
myVis.YAxis.Scale.LabelLayout = ScaleLabelLayout.Automatic
Welcome!

The purpose of this website is to provide a comprehensive, accurate, and efficient IronPython reference for Spotfire developers.

If you have any questions, comments, or ideas, feel free to get in touch!