Parcats
Overview
The parcats
trace type is used to create parallel categories diagrams, which are useful for visualizing categorical data across multiple dimensions. It allows you to see how data flows through different categories and compare the distribution of values across them.
You can customize the colors, line widths, and category order to represent your data and patterns effectively.
Common Uses
- Categorical Data Visualization: Visualizing relationships between different categorical variables.
- Flow Analysis: Showing how data is distributed across multiple dimensions and comparing those paths.
- Segmentation: Visualizing how different segments of data flow through categories.
Check out the Attributes for the full set of configuration options
Examples
Common Configurations
Here's a simple parcats
plot showing how data flows across two categorical variables:
You can copy this code below to create this chart in your project:
models:
- name: parcats-data
args:
- echo
- |
category_1,category_2,value
A,X,30
A,Y,20
B,X,25
B,Y,25
traces:
- name: Simple Parcats Plot
model: ${ref(parcats-data)}
props:
type: parcats
dimensions:
- label: "Category 1"
values: ?{category_1}
- label: "Category 2"
values: ?{category_2}
line:
color: ?{value}
colorscale: "Viridis"
charts:
- name: Simple Parcats Chart
traces:
- ${ref(Simple Parcats Plot)}
layout:
title:
text: Simple Parcats Chart<br><sub>Parallel Categories Diagram</sub>
This example demonstrates a parcats
plot with multiple categorical dimensions, showing how data flows across three categories:
Here's the code:
models:
- name: parcats-data-multi
args:
- echo
- |
category_1,category_2,category_3,value
A,X,Alpha,30
A,Y,Beta,20
B,X,Alpha,25
B,Y,Gamma,25
traces:
- name: Parcats Plot with Multiple Dimensions
model: ${ref(parcats-data-multi)}
props:
type: parcats
dimensions:
- label: "Category 1"
values: ?{category_1}
- label: "Category 2"
values: ?{category_2}
- label: "Category 3"
values: ?{category_3}
line:
color: ?{value}
colorscale: "Blues"
charts:
- name: Parcats Chart with Multiple Dimensions
traces:
- ${ref(Parcats Plot with Multiple Dimensions)}
layout:
title:
text: Parcats Chart with Multiple Dimensions<br><sub>Flow Across Three Categories</sub>
This example shows a parcats
plot with custom line widths based on a value, allowing for the thickness of the lines to represent the volume of data:
Here's the code:
models:
- name: parcats-data-linewidth
args:
- echo
- |
category_1,category_2,value
A,X,50
A,Y,30
B,X,40
B,Y,20
traces:
- name: Parcats Plot with Custom Line Widths
model: ${ref(parcats-data-linewidth)}
props:
type: parcats
dimensions:
- label: "Category 1"
values: ?{category_1}
- label: "Category 2"
values: ?{category_2}
line:
color: ?{value}
width: ?{value}
colorscale: "Jet"
charts:
- name: Parcats Chart with Custom Line Widths
traces:
- ${ref(Parcats Plot with Custom Line Widths)}
layout:
title:
text: Parcats Chart with Custom Line Widths<br><sub>Custom Line Width Based on Values</sub>
A schema to validate plotly trace properties
Attributes
These attributes apply to traces where trace.props.type
is set to parcats
. You would configure these attributes on the trace with the trace.props
object.
arrangement: 'any' #(1)!
bundlecolors: 'boolean' #(2)!
counts: 'number | array' #(3)!
countssrc: 'string' #(4)!
dimensions: array
domain:
column: 'integer' #(5)!
row: 'integer' #(6)!
x: 'array' #(7)!
y: 'array' #(8)!
hoverinfo: 'string' #(9)!
hoveron: 'any' #(10)!
hovertemplate: 'string' #(11)!
labelfont:
color: any
family: 'string' #(12)!
lineposition: 'string' #(13)!
shadow: 'string' #(14)!
size: number
style: 'any' #(15)!
textcase: 'any' #(16)!
variant: 'any' #(17)!
weight: 'integer' #(18)!
legendgrouptitle:
font:
color: any
family: 'string' #(19)!
lineposition: 'string' #(20)!
shadow: 'string' #(21)!
size: number
style: 'any' #(22)!
textcase: 'any' #(23)!
variant: 'any' #(24)!
weight: 'integer' #(25)!
text: 'string' #(26)!
legendwidth: 'number' #(27)!
line:
autocolorscale: 'boolean' #(28)!
cauto: 'boolean' #(29)!
cmax: 'number' #(30)!
cmid: 'number' #(31)!
cmin: 'number' #(32)!
color: 'color | array' #(33)!
coloraxis: 'string' #(34)!
colorbar:
bgcolor: 'any' #(35)!
bordercolor: 'any' #(36)!
borderwidth: 'number' #(37)!
exponentformat: 'any' #(38)!
len: 'number' #(39)!
lenmode: 'any' #(40)!
minexponent: 'number' #(41)!
nticks: 'integer' #(42)!
orientation: 'any' #(43)!
outlinecolor: 'any' #(44)!
outlinewidth: 'number' #(45)!
separatethousands: 'boolean' #(46)!
showexponent: 'any' #(47)!
showticklabels: 'boolean' #(48)!
showtickprefix: 'any' #(49)!
showticksuffix: 'any' #(50)!
thickness: 'number' #(51)!
thicknessmode: 'any' #(52)!
tickangle: 'number' #(53)!
tickcolor: 'any' #(54)!
tickfont:
color: any
family: 'string' #(55)!
lineposition: 'string' #(56)!
shadow: 'string' #(57)!
size: number
style: 'any' #(58)!
textcase: 'any' #(59)!
variant: 'any' #(60)!
weight: 'integer' #(61)!
tickformat: 'string' #(62)!
tickformatstops: array
ticklabeloverflow: 'any' #(63)!
ticklabelposition: 'any' #(64)!
ticklabelstep: 'integer' #(65)!
ticklen: 'number' #(66)!
tickmode: 'any' #(67)!
tickprefix: 'string' #(68)!
ticks: 'any' #(69)!
ticksuffix: 'string' #(70)!
ticktext: 'array' #(71)!
ticktextsrc: 'string' #(72)!
tickvals: 'array' #(73)!
tickvalssrc: 'string' #(74)!
tickwidth: 'number' #(75)!
title:
font:
color: any
family: 'string' #(76)!
lineposition: 'string' #(77)!
shadow: 'string' #(78)!
size: number
style: 'any' #(79)!
textcase: 'any' #(80)!
variant: 'any' #(81)!
weight: 'integer' #(82)!
side: 'any' #(83)!
text: 'string' #(84)!
x: 'number' #(85)!
xanchor: 'any' #(86)!
xpad: 'number' #(87)!
xref: 'any' #(88)!
y: 'number' #(89)!
yanchor: 'any' #(90)!
ypad: 'number' #(91)!
yref: 'any' #(92)!
colorscale: 'any' #(93)!
colorsrc: 'string' #(94)!
hovertemplate: 'string' #(95)!
reversescale: 'boolean' #(96)!
shape: 'any' #(97)!
showscale: 'boolean' #(98)!
metasrc: 'string' #(99)!
name: 'string' #(100)!
sortpaths: 'any' #(101)!
stream:
maxpoints: 'number' #(102)!
token: 'string' #(103)!
tickfont:
color: any
family: 'string' #(104)!
lineposition: 'string' #(105)!
shadow: 'string' #(106)!
size: number
style: 'any' #(107)!
textcase: 'any' #(108)!
variant: 'any' #(109)!
weight: 'integer' #(110)!
type: parcats
uid: 'string' #(111)!
visible: 'any' #(112)!
- Sets the drag interaction mode for categories and dimensions. If
perpendicular
, the categories can only move along a line perpendicular to the paths. Iffreeform
, the categories can freely move on the plane. Iffixed
, the categories and dimensions are stationary. - Sort paths so that like colors are bundled together within each category.
- The number of observations represented by each state. Defaults to 1 so that each state represents one observation
- Sets the source reference on Chart Studio Cloud for
counts
. - If there is a layout grid, use the domain for this column in the grid for this parcats trace .
- If there is a layout grid, use the domain for this row in the grid for this parcats trace .
- Sets the horizontal domain of this parcats trace (in plot fraction).
- Sets the vertical domain of this parcats trace (in plot fraction).
- Determines which trace information appear on hover. If
none
orskip
are set, no information is displayed upon hovering. But, ifnone
is set, click and hover events are still fired. - Sets the hover interaction mode for the parcats diagram. If
category
, hover interaction take place per category. Ifcolor
, hover interactions take place per color per category. Ifdimension
, hover interactions take place across all categories per dimension. - 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. This value here applies when hovering over dimensions. Note that*categorycount
, colorcount and bandcolorcount are only available whenhoveron
contains the color flagFinally, the template string has access to variablescount
,probability
,category
,categorycount
,colorcount
andbandcolorcount
. 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>
. - 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 kind of decoration line(s) with text, such as an under, over or through as well as combinations e.g. under+over, etc.
- 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 whether a font should be styled with a normal or italic face from its family.
- Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.
- Sets the variant of the font.
- Sets the weight (or boldness) of the font.
- 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 kind of decoration line(s) with text, such as an under, over or through as well as combinations e.g. under+over, etc.
- 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 whether a font should be styled with a normal or italic face from its family.
- Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.
- Sets the variant of the font.
- Sets the weight (or boldness) of the font.
- Sets the title of the legend group.
- Sets the width (in px or fraction) of the legend for this trace.
- Determines whether the colorscale is a default palette (
autocolorscale: true
) or the palette determined byline.colorscale
. Has an effect only if inline.color
is set to a numerical array. In casecolorscale
is unspecified orautocolorscale
is true, the default palette will be chosen according to whether numbers in thecolor
array are all positive, all negative or mixed. - Determines whether or not the color domain is computed with respect to the input data (here in
line.color
) or the bounds set inline.cmin
andline.cmax
Has an effect only if inline.color
is set to a numerical array. Defaults tofalse
whenline.cmin
andline.cmax
are set by the user. - Sets the upper bound of the color domain. Has an effect only if in
line.color
is set to a numerical array. Value should have the same units as inline.color
and if set,line.cmin
must be set as well. - Sets the mid-point of the color domain by scaling
line.cmin
and/orline.cmax
to be equidistant to this point. Has an effect only if inline.color
is set to a numerical array. Value should have the same units as inline.color
. Has no effect whenline.cauto
isfalse
. - Sets the lower bound of the color domain. Has an effect only if in
line.color
is set to a numerical array. Value should have the same units as inline.color
and if set,line.cmax
must be set as well. - Sets the line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to
line.cmin
andline.cmax
if set. - Sets a reference to a shared color axis. References to these shared color axes are coloraxis, coloraxis2, coloraxis3, etc. Settings for these shared color axes are set in the layout, under
layout.coloraxis
,layout.coloraxis2
, etc. Note that multiple color scales can be linked to the same color axis. - Sets the color of padded area.
- Sets the axis line color.
- Sets the width (in px) or the border enclosing this color bar.
- Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If none, it appears as 1,000,000,000. If e, 1e+9. If E, 1E+9. If power, 1x10^9 (with 9 in a super script). If SI, 1G. If B, 1B.
- Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends.
- Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot fraction or in *pixels. Use
len
to set the value. - Hide SI prefix for 10^n if |n| is below this number. This only has an effect when
tickformat
is SI or B. - Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to
nticks
. Has an effect only iftickmode
is set to auto. - Sets the orientation of the colorbar.
- Sets the axis line color.
- Sets the width (in px) of the axis line.
- If "true", even 4-digit integers are separated
- If all, all exponents are shown besides their significands. If first, only the exponent of the first tick is shown. If last, only the exponent of the last tick is shown. If none, no exponents appear.
- Determines whether or not the tick labels are drawn.
- If all, all tick labels are displayed with a prefix. If first, only the first tick is displayed with a prefix. If last, only the last tick is displayed with a suffix. If none, tick prefixes are hidden.
- Same as
showtickprefix
but for tick suffixes. - Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels.
- Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot fraction or in pixels. Use
thickness
to set the value. - Sets the angle of the tick labels with respect to the horizontal. For example, a
tickangle
of -90 draws the tick labels vertically. - Sets the tick 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 kind of decoration line(s) with text, such as an under, over or through as well as combinations e.g. under+over, etc.
- 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 whether a font should be styled with a normal or italic face from its family.
- Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.
- Sets the variant of the font.
- Sets the weight (or boldness) of the font.
- Sets the tick label formatting rule 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.46
- Determines how we handle tick labels that would overflow either the graph div or the domain of the axis. The default value for inside tick labels is hide past domain. In other cases the default is hide past div.
- Determines where tick labels are drawn relative to the ticks. Left and right options are used when
orientation
is h, top and bottom whenorientation
is v. - Sets the spacing between tick labels as compared to the spacing between ticks. A value of 1 (default) means each tick gets a label. A value of 2 means shows every 2nd label. A larger value n means only every nth tick is labeled.
tick0
determines which labels are shown. Not implemented for axes withtype
log or multicategory, or whentickmode
is array. - Sets the tick length (in px).
- Sets the tick mode for this axis. If auto, the number of ticks is set via
nticks
. If linear, the placement of the ticks is determined by a starting positiontick0
and a tick stepdtick
(linear is the default value iftick0
anddtick
are provided). If array, the placement of the ticks is set viatickvals
and the tick text isticktext
. (array is the default value iftickvals
is provided). - Sets a tick label prefix.
- Determines whether ticks are drawn or not. If , this axis' ticks are not drawn. If outside (inside), this axis' are drawn outside (inside) the axis lines.
- Sets a tick label suffix.
- Sets the text displayed at the ticks position via
tickvals
. Only has an effect iftickmode
is set to array. Used withtickvals
. - Sets the source reference on Chart Studio Cloud for
ticktext
. - Sets the values at which ticks on this axis appear. Only has an effect if
tickmode
is set to array. Used withticktext
. - Sets the source reference on Chart Studio Cloud for
tickvals
. - Sets the tick width (in px).
- 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 kind of decoration line(s) with text, such as an under, over or through as well as combinations e.g. under+over, etc.
- 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 whether a font should be styled with a normal or italic face from its family.
- Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.
- Sets the variant of the font.
- Sets the weight (or boldness) of the font.
- Determines the location of color bar's title with respect to the color bar. Defaults to top when
orientation
if v and defaults to right whenorientation
if h. - Sets the title of the color bar.
- Sets the x position with respect to
xref
of the color bar (in plot fraction). Whenxref
is paper, defaults to 1.02 whenorientation
is v and 0.5 whenorientation
is h. Whenxref
is container, defaults to 1 whenorientation
is v and 0.5 whenorientation
is h. Must be between 0 and 1 ifxref
is container and between -2 and 3 ifxref
is paper. - Sets this color bar's horizontal position anchor. This anchor binds the
x
position to the left, center or right of the color bar. Defaults to left whenorientation
is v and center whenorientation
is h. - Sets the amount of padding (in px) along the x direction.
- Sets the container
x
refers to. container spans the entirewidth
of the plot. paper refers to the width of the plotting area only. - Sets the y position with respect to
yref
of the color bar (in plot fraction). Whenyref
is paper, defaults to 0.5 whenorientation
is v and 1.02 whenorientation
is h. Whenyref
is container, defaults to 0.5 whenorientation
is v and 1 whenorientation
is h. Must be between 0 and 1 ifyref
is container and between -2 and 3 ifyref
is paper. - Sets this color bar's vertical position anchor This anchor binds the
y
position to the top, middle or bottom of the color bar. Defaults to middle whenorientation
is v and bottom whenorientation
is h. - Sets the amount of padding (in px) along the y direction.
- Sets the container
y
refers to. container spans the entireheight
of the plot. paper refers to the height of the plotting area only. - Sets the colorscale. Has an effect only if in
line.color
is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example,[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]
. To control the bounds of the colorscale in color space, useline.cmin
andline.cmax
. Alternatively,colorscale
may be a palette name string of the following list: Blackbody,Bluered,Blues,Cividis,Earth,Electric,Greens,Greys,Hot,Jet,Picnic,Portland,Rainbow,RdBu,Reds,Viridis,YlGnBu,YlOrRd. - Sets the source reference on Chart Studio Cloud for
color
. - 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. This value here applies when hovering over lines.Finally, the template string has access to variablescount
andprobability
. 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>
. - Reverses the color mapping if true. Has an effect only if in
line.color
is set to a numerical array. If true,line.cmin
will correspond to the last color in the array andline.cmax
will correspond to the first color. - Sets the shape of the paths. If
linear
, paths are composed of straight lines. Ifhspline
, paths are composed of horizontal curved splines - Determines whether or not a colorbar is displayed for this trace. Has an effect only if in
line.color
is set to a numerical array. - 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.
- Sets the path sorting algorithm. If
forward
, sort paths based on dimension categories from left to right. Ifbackward
, sort paths based on dimensions categories from right to left. - Sets the maximum number of points to keep on the plots from an incoming stream. If
maxpoints
is set to 50, only the newest 50 points will be displayed on the plot. - The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
- 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 kind of decoration line(s) with text, such as an under, over or through as well as combinations e.g. under+over, etc.
- 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 whether a font should be styled with a normal or italic face from its family.
- Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.
- Sets the variant of the font.
- Sets the weight (or boldness) of the font.
- Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
- Determines whether or not this trace is visible. If legendonly, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).