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
bundlecolors: boolean
counts: array
countssrc: 'string' #(1)!
dimensions: array
domain:
column: integer
row: integer
x: array
y: array
hoverinfo: any
hoveron: any
hovertemplate: 'string' #(2)!
labelfont:
color: any
family: 'string' #(3)!
lineposition: any
shadow: 'string' #(4)!
size: number
style: any
textcase: any
variant: any
weight: integer
legendgrouptitle:
font:
color: any
family: 'string' #(5)!
lineposition: any
shadow: 'string' #(6)!
size: number
style: any
textcase: any
variant: any
weight: integer
text: 'string' #(7)!
legendwidth: number
line:
autocolorscale: boolean
cauto: boolean
cmax: number
cmid: number
cmin: number
color: array
coloraxis: string
colorbar:
bgcolor: any
bordercolor: any
borderwidth: number
exponentformat: any
len: number
lenmode: any
minexponent: number
nticks: integer
orientation: any
outlinecolor: any
outlinewidth: number
separatethousands: boolean
showexponent: any
showticklabels: boolean
showtickprefix: any
showticksuffix: any
thickness: number
thicknessmode: any
tickangle: number
tickcolor: any
tickfont:
color: any
family: 'string' #(8)!
lineposition: any
shadow: 'string' #(9)!
size: number
style: any
textcase: any
variant: any
weight: integer
tickformat: 'string' #(10)!
tickformatstops: array
ticklabeloverflow: any
ticklabelposition: any
ticklabelstep: integer
ticklen: number
tickmode: any
tickprefix: 'string' #(11)!
ticks: any
ticksuffix: 'string' #(12)!
ticktext: array
ticktextsrc: 'string' #(13)!
tickvals: array
tickvalssrc: 'string' #(14)!
tickwidth: number
title:
font:
color: any
family: 'string' #(15)!
lineposition: any
shadow: 'string' #(16)!
size: number
style: any
textcase: any
variant: any
weight: integer
side: any
text: 'string' #(17)!
x: number
xanchor: any
xpad: number
xref: any
y: number
yanchor: any
ypad: number
yref: any
colorscale: any
colorsrc: 'string' #(18)!
hovertemplate: 'string' #(19)!
reversescale: boolean
shape: any
showscale: boolean
metasrc: 'string' #(20)!
name: 'string' #(21)!
sortpaths: any
stream:
maxpoints: number
token: 'string' #(22)!
tickfont:
color: any
family: 'string' #(23)!
lineposition: any
shadow: 'string' #(24)!
size: number
style: any
textcase: any
variant: any
weight: integer
type: parcats
uid: 'string' #(25)!
visible: any
- Sets the source reference on Chart Studio Cloud for
counts
. - 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 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.
- 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.
- 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 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
- Sets a tick label prefix.
- Sets a tick label suffix.
- Sets the source reference on Chart Studio Cloud for
ticktext
. - Sets the source reference on Chart Studio Cloud for
tickvals
. - 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 color bar.
- 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>
. - 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.
- 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 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.
- Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.