// Single View Specification{ "data": ... , "mark": "errorband", "encoding": ... , ...}
An error band summarizes an error range of quantitative values using a set of summary statistics, representing by area. Error band in Vega-Lite can either be used to aggregate raw data or directly visualize aggregated data.
To create an error band, setmark
to"errorband"
.
An error band’s mark definition can contain the following properties:
Property | Type | Description |
---|---|---|
type | ErrorBand | Required. The mark type. This could a primitive mark type (one of |
extent | String | The extent of the band. Available options include:
Default value: |
orient | String | Orientation of the error band. This is normally automatically determined, but can be specified when the orientation is ambiguous and cannot be automatically determined. |
color | Color |Gradient |ExprRef | Default color. Default value:■ Note:
|
opacity | Number | The opacity (value between [0,1]) of the mark. |
interpolate | String | The line interpolation method for the error band. One of the following:
|
tension | Number | The tension parameter for the interpolation type of the error band. |
Besides the properties listed above,band
andborders
can be used to specify the underlyingmark properties for differentparts of the error band as well.
All the properties and usage of error band are identical to error bar’s, except theband
andborders
that replace the error bar’srule
andticks
.
If the data is not aggregated yet, Vega-Lite will aggregate the data based on theextent
properties in the mark definition as done in theerror band showing confidence interval above. All otherextent
values are defined inError Bar.
If the data is already pre-aggregated with low and high values of the error band, you can directly specifyx
andx2
(ory
andy2
) to use error band as a ranged mark.
If the data is already pre-aggregated with center and error values of the error band, you can usex/y
,x/yError
, andx/yError2
as defined inError Bar
Vega-Lite supports both 1D and 2D error bands:
{:#1d} A1D error band shows the error range of a continuous field; it can be used to show the global error range of the whole plot.
{:#2d} A2D error band shows the error range of a continuous field for each dimension value such as year.
Under the hood, theerrorband
mark is acomposite mark that expands into a layered plot. For example,the basic 2D error band shown above is equivalent to:
We can customize different parts of the error bandmark definition orconfig.
For example, we can add the error band’s borders and customize it by settingborders
totrue
or adding a mark property toborders
, such asstrokeDash
andopacity
:
You can customize the color, size, and opacity of the band in theerrorband
by using thecolor
, andopacity
encoding channels, which applied to the wholeerrorband
.
Here is an example of aerrorband
with thecolor
encoding channel set to{"value": "black"}
.
You can add custom tooltips to error bands. The custom tooltip will override the default error band’s tooltips.
{ "errorband": { "extent": ..., "band": ..., "borders": ... }}
Theerrorband
config object sets the default properties forerrorband
marks.
The error band config can contain allerror band mark properties but currently not supportingcolor
,opacity
, andorient
. Please see issue#3934.