There are several ways you can customize the labels on your visualizations. This is done through the Format > DATA LABELS > Annotation menu and is useful for several use cases:
Changing significance arrows, carets or triangles to Bar, Column, Line, and Radar visualizations
Using letters for statistical testing
Circles, circles with borders, and shadows
Creating custom statistics for annotations
This article describes how to go from a visualization that does not display annotations or significance testing:
To a visualization that displays annotations and significance testing:
Requirements
- A Displayr document with at least one table.
- Knowledge of how to create visualizations (See: Creating and Modifying Visualizations)
- Familiarity with the types of significance testing in Displayr (See: How to Apply Significance Testing in Displayr)
Methods
Changing significance arrows, carets or triangles to Bar, Column, Line, and Radar visualizations
- Create a bar, column, line, or radar visualization by selecting an existing table (that doesn't show Column Comparison stat testing).
- From the object inspector, select OUTPUT > Visualization or via the Visualization menu on the toolbar, selecting the table or variables as the DATA SOURCE.
- With the visualization selected, go to Properties > APPEARANCE > Significance and select Advanced from the pull-down menu. By default, Displayr's visualizations have Arrows and Font colors enabled. Use this menu to modify what types of significance tests are run.
- Select the Exception Tests tab and use the Significance Symbol menu to select the symbol you want to use to indicate significance. In this example, we will choose a Triangle.
- Click Apply to Selection.
- OPTIONAL: Use Chart > APPEARANCE > Significance arrow size to adjust the size of the significance arrow (triangle) as necessary.
- OPTIONAL: Use Significance > Advanced > Significance Levels to change the color of the significance symbol as needed.
Using letters for statistical testing
There are two ways of showing column comparison letters on a visualization. One is by using our legacy "with Tests" visualizations, but the available features and way that it is formatted may not meet everyone's needs. If you'd rather use one of our R-based visualizations that include more features and customizations, you can add the letters using an annotation to the data labels.
Method 1 - Using "with Tests" visualization:
- Select your table and click Properties > APPEARANCE > Significance > Advanced.
- Click the Significance Levels tab, and from the Show significance menu, select Compare columns.
- Click Apply to Selection.
- Create a visualization from the Visualization Selector, select the "with Tests" version of the visualization you'd like to create, in this example Column > Column with Tests. If you don't see the "with Tests" visualizations, you'll need to unhide them by checking Show legacy visualizations.
- OPTIONAL: Click Chart to adjust the formatting as necessary.
Later in the post, another example shows how to change all the letters to uppercase.
Method 2 - Using annotations on the visualization:
- Select your table and click Properties > APPEARANCE > Significance > Advanced.
- Click the Significance Levels tab, and from the Show significance menu, select Compare columns.
- Click Apply to Selection.
- Create a visualization from the Visualization Selector, select the visualization that doesn't contain "with Tests", such as Column > Column.
- Check Chart > DATA LABELS > Show data values box.
- Select DATA LABELS > Annotation(1) > Text - after label.
- Make Data (cell statistic) (1) set to Column Comparisons, and keep the Threshold (1) blank.
- [OPTIONAL] further customize the formatting of the stat testing annotation.
Circles, circles with borders, and shadows
In addition to arrows, carets, and text, it is possible to add a border around the data labels, which appears as a filled circle, empty circle with border, or shadow. These are selected as follows:
- Select Chart > DATA LABELS.
- Check the Show data values box.
- Select DATA LABELS > Annotation(1).
There are formatting options for controlling their size, colors, and line thicknesses.
In the example below, I've used the Circle - thick outline annotation type and adjusted the Size (1) setting:
Hiding labels
By setting Annotation (1) to Hide, rules can be used to hide annotations. For example, in the chart below, all non-significant labels have been hidden. Note that this also hides the data label.
Creating custom statistics for annotations
All the examples so far have used existing tables and their statistics to create the annotations. However, you can create your own custom statistic to annotate your visualization using R code. You'll take your table, create a new table within R with the custom statistic/calculations, and combine the two together, see How to Combine Tables with Multiple Statistics Using R. You'll then reference that new calculation in the Annotation menu to apply your annotations.
You can also modify a statistic that's already in your table. In this example, the following code modifies a table called table.Preferred.cola.2.by.Age.6, by making all the column comparisons appear as uppercase. This modified table is then used as the input to the visualization.
x = table.Preferred.cola.2.by.Age.6
x[,,"Column Comparisons"] = toupper(x[,,"Column Comparisons"])
table.with.upper.case.stats = x
This last example creates a table, with a completely new statistic, called Comment and passes this through to the bar chart, with two annotations. Annotation (1) is set to Hide (to hide the labels) and Annotation (2) to Text - after label with Data (cell statistic) (2) set to Comment.
Looking at the R code used to create the table with the comment, key features are:
- A 3-dimensional array is created called out (this is the required structure of a table for use with annotation). Note that this three dimensional array is a table, where there are multiple results in each cell of the table. In this case, the table has 12 rows and 1 column, where nrow(x) is the 12 rows of the table called table.Interview.Date (shown on the left). The first result in the cells of the table is % and the second is Comment.
- The Comment has been set to blank, except for July 2019, which has been set as New\ncampaign, where \n is the code for a new line.
NEXT
How to Apply Multiple Comparison Correction to Significance Tests
Creating and Modifying Visualizations
How to Work with R in Displayr