TIBCO Cloud™ Spotfire® User Guide

Adding error bars

Typically, error bars are used to visualize uncertainty in the data. You can add them to bar charts, line charts, and scatter plots.

About this task

You can also use error bars to indicate also other types of ranges than uncertainty in values, because you have various options to define what the error bar lengths should represent. The examples following the procedure show different use cases.

Procedure

  1. Locate the Error bars section in the visualization properties.
  2. Under Show the following error bars in the visualization properties panel, or, under Visible error bars in the dialog or popover, add or select Vertical to draw vertical error bars, and Horizontal to draw horizontal error bars.
    The Horizontal option is only available in scatter plots.
  3. Use the Upper error and Lower error selectors to specify what type of range to show. See the examples below for different options.
    Note: The selected column or measure must have numerical values.
    Note: The error bars are by default drawn relative to the visualization item position in the visualization. For horizontal error bars in a scatter plot with non-reversed scales, the upper error refers to the error bar on the right-hand side of the marker, and the lower error refers to the error bar on the left-hand side of the marker..
  4. Specify the Color of the error bars:
    • Select Same as visualization item (or Same as marker/Use marker color) to let an error bar have the same color as the related item. Note that, in a bar chart, for positive bars, the lower error bar will be invisible if this option is selected, and for negative bars, the upper error bar will be invisible.
    • Select Custom to access a palette to specify a different color.
  5. Select whether to Show end caps of the error bars.
  6. Select Include error bars in axis range to always show the entire error bars. This means that the range of the axis scale is extended automatically in the visualization to make the error bars totally visible.

Error bars based on an aggregation

The bar chart shows the average sales per month during one year. To show the uncertainty in the values, the pre-defined aggregation method standard error (StdErr) has been used to calculate the length of the error bars.


Error bars based on aggregation
The setting is shown below (as it looks in the visualization properties panel). The StdErr aggregation is specified on the Upper error selector.


A long error bar in this example means that the concentration of values, which the sales average was calculated on, is low, and thus the average value is uncertain. Conversely, a short error bar means that the concentration of values is high, and thus, that the average value is more certain.

Error bars based on absolute column values

The data table below lists already calculated averages and estimated upper and lower errors in absolute values. By setting the Upper error to the 'Absolute upper error' column (for the 'Average' axis) and the Lower error to the 'Absolute lower error' column in a scatter plot, the error bars for each average value represent the actual values in the two error columns.


Error bars based on absolute figures

Error bars based on a custom expression

Instead of using a pre-defined aggregation method, you can specify the length of the error bars by writing your own expression. This is an example where custom expressions are used.

This simple data table lists eight sales transactions.



Assume you are interested in visualizing the average sales amount per category in a bar chart, and also in showing between which amounts the transactions vary by means of error bars. Then a custom expression is needed for the error bar calculations. If you directly use the pre-defined Max() and Min() aggregation methods for the amount column as shown below, the variation is drawn incorrectly. It should, for example, be 100-1000 for fruits instead of 400-1500. This is because the error bars are always drawn relative to the marker, meaning the upper end cap equals the sum of the average amount and the max amount (for example, 700+1200 for vegetables).



To show what you intended, right-click the Upper error selector, select Custom expression, and enter the expression that subtracts the average value from the max value:

Max([Amount]) - Avg([Amount])

In the same way, for the Lower error, enter the expression:

Avg([Amount]) - Min([Amount])


Now the error bars in the bar chart show between which amounts the transactions vary.