Combo Charts on Different Y Axes#

Plotting charts with mixes series of lines and bars is possible, as well as plotting them on different Y-axes.

  • Define a y2_axis in the chart function. Configure the secondary axis for axis_type and formatting based on the series that will be plotted on it.

  • Assign series to the y2_axis by setting location=="y2".

  • Multiple series can exist on either axis depending the location argument.

  • Series by default are plotted on the y1_axis.



import pandas as pd

from visualization_toolkit.helpers.plotly import chart, axis, series


fig = chart(
    pdf,
    x_axis=axis(column_name="fiscal_qy", label="Fiscal Quarter"),
    y1_axis=axis(label="Downloads", axis_type="number", axis_max=250000),
    y2_axis=axis(label="Growth Rate", axis_type="percent"),
    chart_series=[
        series(
            column_name="ucan",
            label="UCAN",
            color="light-blue",
            mode="bar",
            is_stacked=True,
        ),
        series(
            column_name="china",
            label="China",
            color="light-grey",
            mode="bar",
            is_stacked=True,
        ),
        series(
            column_name="yy",
            label="Y/Y Growth Rate",
            color="black",
            location="y2",
            shape="dash",
        ),
    ],
)

fig

Total running time of the script: (0 minutes 0.024 seconds)

Gallery generated by Sphinx-Gallery