Labels

These IronPython scripts below show how to modify any of the Scatter Plot visualization settings found on the Labels tab of the Scatter Plot Properties dialog box in the Spotfire user interface.
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 Scatter Plot Labels Tab Options:

  1. Change the “Label by” custom expression
  2. Show labels for all, marked rows, or none
  3. Set max number of labels
  4. Center labels on items
  5. Show empty labels
  6. Show label as Link, Text, or Image from URL
  7. Set the URL template for “Link” or “Image from URL”
  8. Set label image size
from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Application.Visuals.ValueRenderers import *

myVis = myVis.As[Visualization]()

# 1. Change the "Label by" custom expression
myVis.LabelColumn.Expression = "[Column A]"

# 2. Show labels for all, marked rows, or none
myVis.LabelVisibility = LabelVisibility.All
# OR
myVis.LabelVisibility = LabelVisibility.Marked
# OR
myVis.LabelVisibility = LabelVisibility.None

# 3. Set max number of labels
myVis.MaxNumberOfLabels = 50  #Any integer from 0 to 200 is allowed

# 4. Center labels on items
myVis.MarkerLabelLayout = MarkerLabelLayout.Center  #Checkbox checked
# OR
myVis.MarkerLabelLayout = MarkerLabelLayout.Auto  #Checkbox un-checked

# 5. Show empty labels
myVis.ShowEmptyLabels = True

# 6. Show label as Link, Text, or Image from URL
# Show label as a link:
linkRenderer = myVis.SetLabelRenderer( ValueRendererTypeIdentifiers.LinkRenderer)
# OR
# Show label as text:
myVis.SetLabelRenderer(ValueRendererTypeIdentifiers.DefaultRenderer)
# OR
# Show label as an image from URL:
imageRenderer = myVis.SetLabelRenderer(ValueRendererTypeIdentifiers.ImageFromUrlRenderer)

# 7. Set the URL template for "Link" or "Image from URL" options above
# Notice that linkRenderer and imageRenderer are set in the section above
# The URL template is a string where {$} will be replaced by a data value
linkRenderer.LinkTemplate = "{$}.com"
# OR
imageRenderer.UrlTemplate = "{$}.com"

# 8. Set label image size
myVis.LabelImageSize = 20  #Any integer from 0 to 100 is allowed
# Label image size info from the TIBCO Spotfire API Documentation:
# The labels size is expressed as a percentage of the size of the panel in 
# the range of minimum 15 pixels and maximum the least of the width or height. 
# I.e. a value of 0 will allow images as large as 15 x 15 pixels, and a value of
# 100 will allow images as large as the least of the width or the height of the panel.
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.

Welcome!

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