Introduction
Using labels for markers on a map or scatter plot may provide useful information and clarity, but when there are many markers on the plot, labeling all markers may not be desirable.
Luckily, Spotfire provides a way of selecting which markers to display in maps and scatterplots based on a custom expression on the Label axis.
In the attached DXP file you can see three different ways of labeling the markers:
- Label only selected stores
- Label the top 10 selling stores (taking filtering into account)
- Label selected stores through tags (iterate your way to a good set of labels by tagging those markers)
In all three cases, the technique used is to use a custom expression with an IF or CASE statement on the label, that sets the label content to whatever is desired if the logical condition is true, and sets the label content to NULL if the condition is false. Labels that have the value NULL are not shown by Spotfire by default (check that the "show empty labels" checkbox is unchecked).
Label selected stores only
To select specific stores to label the following expression works.
CASE when [Store Name]="Marlon Gary" then [Store Name] when [Store Name]="Myrna Newman" THEN [Store Name] when [Store Name]="Mike Irons" THEN [Store Name] when [Store Name]="Wim Fellini" THEN [Store Name] ELSE NULL END
Label top 10 stores
To label the top 10 selling stores in the current filtering the following expression works:
If(Rank([Class Sales],"desc")<11,[store Name],NULL)
Label selected stores through tags
Select View > Tags to show the tags panel. Tag collections can be added to a data table, and are essentially a new column where each row is untagged by default. You can add tags to your collection, and then attach them to select rows, by marking data rows in the visualization, and then drag & dropping the tag to attach it. Check out the online help for details on how to work with the Tags panel.
To show labels only for tagged rows the following expression works:
If([Markers to label]!="",[City],NULL)
Instead of just having a single tag for when to show labels, you can include several tags in your collection, and fetch the labels from different columns for each as in this expression:
CASE when [Choice of labels]="Type" then [Store Type] when [Choice of labels]="Store" then [Store Name] ELSE NULL END
Just add another line for each new tag you add to your collection to specify which column to use for labelling those data rows.
The second page in the attached analysis file shows the Tags panel with these example tag collections and a scatter plot for each. You don't need to keep the Tags panel open once you are done iterating which data points to tag, and thus label.
Hope you find this useful and please don't hesitate to ask questions by using the 'ask a question' option on the community, please include the URL of this article in your question.
Recommended Comments
There are no comments to display.