Statsplotly provides a high-level, declarative API for drawing statistical visualization with plotly.
Compared to the plotly.express API, statsplotly color coding scheme, slicer and plot dimensions are independent.
This independence allows to leverage the powerful interactivity offered by plotly.js without compromising statistical intelligibility for aesthetics choices, or vice-versa.
Functions signature¶
All plotting functions return a plotly.graph_objects.Figure object, and must be supplied with :
a
pandas.DataFrame-comptatible data structure. Dictionaries or tidy (i.e., long-form) DataFrames are the recommended entry point. Note that hierarchical indexes are supported only on DataFrame’sindex.column or index identifiers to specify
x,yandz-when applicable- plotting dimensions.
💡 Read more on tidy data.
All plotting functions also accept:
a
slicerargument to slice the data along a particular dimension : each slice of the data is drawed as an independentplotly.jstrace. Depending on the graphic representation, traces can be toggled via legend clicking, or dropdown selection.a
color_paletteargument which can be :a string refering to a built-in plotly, seaborn or matplotlib colormap.
a list of CSS color names or HTML color codes: The color palette is used, by order of precedence :
To map color data specified by the
colorparameter onto the corresponding colormap.to assign discrete colors to
slicesof data.
String color data are interpreted as “discrete” (i.e., interval) colorscale. To specify a continuous colorscale, color data should be casted to numeric dtype.
an
axisargument to specify axes limits and aspect ratio. Theequalandsquarestyles of Matlab API are supported.a
titleargument to replace the default title assembled from the dimension names.a
fig,row,coltriplet argument to draw a subplot on aFigureobject pre-declared withplotly.subplots.make_subplots.
Additional arguments can be provided, depending on the visualization selected.