Statsplotly Logo Statsplotly Logo

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.graphic_objects.Figure object, and must be supplied with :

  • a tidy (i.e., long-form) pandas.DataFrame argument for data, with a flat header (hierarchical indexes are supported).

  • column or index identifiers to specify x, y and z -when applicable- plotting dimensions.

💡 Read more on tidy data.

All plotting functions also accept:

  • a slicer argument to slice the data along a particular dimension : each slice of the data is drawed as an independent plotly.js trace. Depending on the graphic representation, traces can be toggled via legend clicking, or dropdown selection.

  • a color_palette argument 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 color parameter onto the corresponding colormap.

      • to assign discrete colors to slices of 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 axis argument to specify axes limits and aspect ratio. The equal and square styles of Matlab API are supported.

  • a title argument to replace the default title assembled from the dimension names.

  • a fig, row, col triplet argument to draw a subplot on a Figure object pre-declared with plotly.subplots.make_subplots.

Additional arguments can be provided, depending on the visualization selected.

Features#

API#

Indices and tables#

Changelog#