Box
Overview
The box
trace type is used to display data as a box plot, which shows the distribution of data based on their quartiles, medians, and potential outliers. It's useful for statistical visualizations, as it highlights data spread and central tendency while accounting for variability.
You can control various aspects of the plot, such as the orientation, box and whisker styles, marker symbols, and points display. Additionally, you can show or hide outliers and configure hover labels for enhanced interaction.
Common Uses
- Distribution Analysis: Understanding the distribution of quest-related data.
- Outlier Detection: Identifying outliers in quest performance metrics.
- Comparative Analysis: Comparing the performance of knights on different quests.
Check out the Attributes for the full set of configuration options
Examples
Common Configurations
Here's a simple box
plot showing the distribution of sample data:
You can copy this code below to create this chart in your project:
models:
- name: sample-data
args:
- echo
- |
category,value
A,23
A,15
A,18
A,30
A,28
B,40
B,35
B,31
B,25
B,29
traces:
- name: Sample Box Plot
model: ${ref(sample-data)}
props:
type: box
x: ?{category}
y: ?{value}
boxpoints: "all"
jitter: 1
pointpos: -1.1
charts:
- name: Sample Box Plot Chart
traces:
- ${ref(Sample Box Plot)}
layout:
title:
text: Simple Box Plot<br><sub>Distribution of Values by Category</sub>
xaxis:
title:
text: "Category"
yaxis:
title:
text: "Value"
Here's a box
plot showing the distribution of rewards earned by knights across different quests:
You can copy this code below to create this chart in your project:
models:
- name: monty-python-quest-data-unique
args:
- curl
- "https://raw.githubusercontent.com/visivo-io/data/refs/heads/main/monty_python_quests.csv"
traces:
- name: Rewards Distribution by Quest
model: ${ref(monty-python-quest-data-unique)}
cohort_on: "person"
props:
type: box
y: ?{person}
x: ?{reward_gbp}
boxpoints: "all"
jitter: 1
pointpos: -1.1
orientation: h
charts:
- name: Rewards Distribution Box Plot
traces:
- ${ref(Rewards Distribution by Quest)}
layout:
title:
text: Horizontal Box Plot<br><sub>GBP Rewards Earned Across Quests</sub>
xaxis:
title:
text: "Reward (GBP)"
In this example, we show how to display a box plot for the number of proclamations mades:
Here's the code:
models:
- name: monty-python-quest-proclamations
args:
- curl
- "https://raw.githubusercontent.com/visivo-io/data/refs/heads/main/monty_python_quests.csv"
traces:
- name: Proclamations Box Plot
model: ${ref(monty-python-quest-proclamations)}
cohort_on: "person"
props:
type: box
y: ?{proclamations_made}
x: ?{enemy_encountered}
charts:
- name: Proclamations Box Plot with Outliers
traces:
- ${ref(Proclamations Box Plot)}
layout:
title:
text: Cohorted Box Plot<br><sub>Proclamations Made Across Quests by Enemy</sub>
xaxis:
title:
text: "Enemy"
boxmode: group
yaxis:
title:
text: "Proclamations Made"
A schema to validate plotly trace properties
Attributes
These attributes apply to traces where trace.props.type
is set to box
. You would configure these attributes on the trace with the trace.props
object.
alignmentgroup: 'string' #(1)!
boxmean: any
boxpoints: any
customdata: array
customdatasrc: 'string' #(2)!
dx: number
dy: number
fillcolor: any
hoverinfo: array
hoverinfosrc: 'string' #(3)!
hoverlabel:
align: array
alignsrc: 'string' #(4)!
bgcolor: array
bgcolorsrc: 'string' #(5)!
bordercolor: array
bordercolorsrc: 'string' #(6)!
font:
color: array
colorsrc: 'string' #(7)!
family: 'string | array' #(8)!
familysrc: 'string' #(9)!
lineposition: array
linepositionsrc: 'string' #(10)!
shadow: 'string | array' #(11)!
shadowsrc: 'string' #(12)!
size: array
sizesrc: 'string' #(13)!
style: array
stylesrc: 'string' #(14)!
textcase: array
textcasesrc: 'string' #(15)!
variant: array
variantsrc: 'string' #(16)!
weight: array
weightsrc: 'string' #(17)!
namelength: array
namelengthsrc: 'string' #(18)!
hoveron: string
hovertemplate: 'string | array' #(19)!
hovertemplatesrc: 'string' #(20)!
hovertext: 'string | array' #(21)!
hovertextsrc: 'string' #(22)!
ids: array
idssrc: 'string' #(23)!
jitter: number
legend: string
legendgroup: 'string' #(24)!
legendgrouptitle:
font:
color: any
family: 'string' #(25)!
lineposition: any
shadow: 'string' #(26)!
size: number
style: any
textcase: any
variant: any
weight: integer
text: 'string' #(27)!
legendrank: number
legendwidth: number
line:
color: any
width: number
lowerfence: array
lowerfencesrc: 'string' #(28)!
marker:
angle: number
color: any
line:
color: any
outliercolor: any
outlierwidth: number
width: number
opacity: number
outliercolor: any
size: number
symbol: any
mean: array
meansrc: 'string' #(29)!
median: array
mediansrc: 'string' #(30)!
metasrc: 'string' #(31)!
name: 'string' #(32)!
notched: boolean
notchspan: array
notchspansrc: 'string' #(33)!
notchwidth: number
offsetgroup: 'string' #(34)!
opacity: number
orientation: any
pointpos: number
q1: array
q1src: 'string' #(35)!
q3: array
q3src: 'string' #(36)!
quartilemethod: any
sd: array
sdmultiple: number
sdsrc: 'string' #(37)!
selected:
marker:
color: any
opacity: number
size: number
showlegend: boolean
showwhiskers: boolean
sizemode: any
stream:
maxpoints: number
token: 'string' #(38)!
text: 'string | array' #(39)!
textsrc: 'string' #(40)!
type: box
uid: 'string' #(41)!
unselected:
marker:
color: any
opacity: number
size: number
upperfence: array
upperfencesrc: 'string' #(42)!
visible: any
whiskerwidth: number
width: number
x: array
xaxis: string
xcalendar: any
xhoverformat: 'string' #(43)!
xperiodalignment: any
xsrc: 'string' #(44)!
y: array
yaxis: string
ycalendar: any
yhoverformat: 'string' #(45)!
yperiodalignment: any
ysrc: 'string' #(46)!
zorder: integer
- Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently.
- Sets the source reference on Chart Studio Cloud for
customdata
. - Sets the source reference on Chart Studio Cloud for
hoverinfo
. - Sets the source reference on Chart Studio Cloud for
align
. - Sets the source reference on Chart Studio Cloud for
bgcolor
. - Sets the source reference on Chart Studio Cloud for
bordercolor
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
namelength
. - Template string used for rendering the information that appear on hover box. Note that this will override
hoverinfo
. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%xother}, {%_xother}, {%xother_}. When showing info for several points, xother will be added to those with different x positions from the first point. An underscore before or after (x|y)other will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available inhovertemplate
are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. Anything contained in tag<extra>
is displayed in the secondary box, for example "{fullData.name} ". To hide the secondary box completely, use an empty tag<extra></extra>
. - Sets the source reference on Chart Studio Cloud for
hovertemplate
. - Same as
text
. - Sets the source reference on Chart Studio Cloud for
hovertext
. - Sets the source reference on Chart Studio Cloud for
ids
. - Sets the legend group for this trace. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items.
- HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the legend group.
- Sets the source reference on Chart Studio Cloud for
lowerfence
. - Sets the source reference on Chart Studio Cloud for
mean
. - Sets the source reference on Chart Studio Cloud for
median
. - Sets the source reference on Chart Studio Cloud for
meta
. - Sets the trace name. The trace name appears as the legend item and on hover. For box traces, the name will also be used for the position coordinate, if
x
andx0
(y
andy0
if horizontal) are missing and the position axis is categorical - Sets the source reference on Chart Studio Cloud for
notchspan
. - Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up.
- Sets the source reference on Chart Studio Cloud for
q1
. - Sets the source reference on Chart Studio Cloud for
q3
. - Sets the source reference on Chart Studio Cloud for
sd
. - The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
- Sets the text elements associated with each sample value. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. To be seen, trace
hoverinfo
must contain a text flag. - Sets the source reference on Chart Studio Cloud for
text
. - Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
- Sets the source reference on Chart Studio Cloud for
upperfence
. - Sets the hover text formatting rulefor
x
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingxaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
x
. - Sets the hover text formatting rulefor
y
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingyaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
y
.