Sub plots

Multiple sub plots can be combined into one plot using the make_subplots function. This function accepts multiple plot objects, and returns a single plot object. The plot objects can be any of the plot types supported by Deephaven Express. They can be arranged in a grid, or in a single row or column. The shared_xaxes and shared_yaxes parameters can be used to share axes between plots.

Examples

Four unique plots

Create a series of plots as subplots, all providing unique perspectives on the data of interest.

import deephaven.plot.express as dx
tips = dx.data.tips() # import a ticking version of the Tips dataset

# create 4 plots from within make_subplots
tipping_plots = dx.make_subplots(
    dx.scatter(tips, x="TotalBill", y="Tip", by="Sex",
        title="Tip amount by total bill"),
    dx.violin(tips, y="TotalBill", by="Day",
        title="Total bill distribution by day"),
    dx.pie(
        tips
        .count_by("Count", by=["Sex", "Smoker"])
        .update_view("SmokerStatus = Smoker == `No` ? `non-smoker` : `smoker`")
        .update_view("SmokerLabel = Sex + ` ` + SmokerStatus"),
        names="SmokerLabel", values="Count",
        title="Total bill by sex and smoking status"),
    dx.bar(tips
        .view(["TotalBill", "Tip", "Day"])
        .avg_by("Day"),
        x="Day", y=["TotalBill", "Tip"],
        title="Average tip as a fraction of total bill"),
    rows=2, cols=2, shared_xaxes=False, shared_yaxes=False
)

API Reference

Create subplots. Either figs and at least one of rows and cols or grid should be passed.

Returns: DeephavenFigure The DeephavenFigure with subplots

ParametersTypeDefaultDescription
*figsFigure |
DeephavenFigure
Figures to use. Should be used with rows and/or cols.
rowsint0A list of rows in the resulting subplot grid. This is calculated from cols and number of figs provided if not passed but cols is. One of rows or cols should be provided if passing figs directly.
colsint0A list of cols in the resulting subplot grid. This is calculated from rows and number of figs provided if not passed but rows is. One of rows or cols should be provided if passing figs directly.
shared_xaxesstr |
bool |
None
None"rows", "cols"/True, "all" or None depending on what axes should be shared
shared_yaxesstr |
bool |
None
None"rows"/True, "cols", "all" or None depending on what axes should be shared
gridList[List[Figure | DeephavenFigure]] |
None
NoneA grid (list of lists) of figures to draw. None can be provided in a grid entry
horizontal_spacingfloat |
None
NoneSpacing between each column. Default 0.2 / cols
vertical_spacingfloat |
None
NoneSpacing between each row. Default 0.3 / rows
column_widthslist[float] |
None
NoneThe widths of each column. Should sum to 1.
row_heightslist[float] |
None
NoneThe heights of each row. Should sum to 1.
specslist[SubplotSpecDict] |
List[List[SubplotSpecDict]] |
None
None(Default value = None) A list or grid of dicts that contain specs. An empty dictionary represents no specs, and None represents no figure, either to leave a gap on the subplots on provide room for a figure spanning multiple columns. 'l' is a float that adds left padding 'r' is a float that adds right padding 't' is a float that adds top padding 'b' is a float that adds bottom padding 'rowspan' is an int to make this figure span multiple rows 'colspan' is an int to make this figure span multiple columns
unsafe_update_figureCallable<function default_callback>An update function that takes a plotly figure as an argument and optionally returns a plotly figure. If a figure is not returned, the plotly figure passed will be assumed to be the return value. Used to add any custom changes to the underlying plotly figure. Note that the existing data traces should not be removed. This may lead to unexpected behavior if traces are modified in a way that break data mappings.