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 Line Chart X-Axis Tab Options:
This IronPython script shows how to change the following options, in order from top-left to bottom-right on the x-axis tab in the Spotfire user interface:
- Change the x-axis expression
- Set the range min and max
- Include origin
- Show zoom slider
- Show gridlines
- Use log scale
- Reverse scale
- Show (or hide) scale labels
- Show labels horizontally or vertically
- Set max number of labels
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.XAxis.Expression = "[My Column]" # 2. Set the range min and max # Enter as AxisRange([minimum], [maximum]) to set the range myVis.XAxis.Range = AxisRange(50, 250) # OR # Enter None keyword to set either end of the range back to "Automatic" myVis.XAxis.Range = AxisRange(None, None) # 3. Include origin myVis.XAxis.IncludeZeroInAutoZoom = True # 4. Show zoom slider myVis.XAxis.ManualZoom = True # 5. Show gridlines myVis.XAxis.Scale.ShowGridlines = True # 6. Use log scale myVis.XAxis.TransformType = AxisTransformType.Log10 #Checked # OR myVis.XAxis.TransformType = AxisTransformType.None #Un-checked # 7. Reverse scale myVis.XAxis.Reversed = True # Note: If axis is reversed, be sure to reverse AxisRange in #2 above as well # 8. Show (or hide) scale labels myVis.XAxis.Scale.ShowLabels = True # 9. Show labels horizontally or vertically myVis.XAxis.Scale.LabelOrientation = LabelOrientation.Horizontal # OR myVis.XAxis.Scale.LabelOrientation = LabelOrientation.Vertical # 10. Set max number of labels # To check the "Max number of labels" checkbox and set the number: myVis.XAxis.Scale.LabelLayout = ScaleLabelLayout.MaximumNumberOfTicks myVis.XAxis.Scale.MaximumNumberOfTicks = 15 # OR # To un-check the "Max number of labels" checkbox and ignore the number: myVis.XAxis.Scale.LabelLayout = ScaleLabelLayout.Automatic
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!