Single-Sided Violin Plot#

See also

API Documentation: plot_violin()

../_images/mpl_plot_violin_single_sided.png
import matplotlib.pyplot as plt

import arviz as az

az.style.use("arviz-doc")

data = az.load_arviz_data("rugby")

labeller = az.labels.MapLabeller(var_name_map={"defs": "atts | defs"})
axes = az.plot_violin(
    data,
    var_names=["atts"],
    side="left",
    show=False,
    figsize=(11.5, 5),
)
az.plot_violin(
    data,
    var_names=["defs"],
    side="right",
    labeller=labeller,
    ax=axes,
    show=True,
)

fig = axes.flatten()[0].get_figure()
fig.suptitle("Attack/Defense of Rugby Teams")
fig.tight_layout()

plt.show()
import arviz as az

data = az.load_arviz_data("rugby")
labeller = az.labels.MapLabeller(var_name_map={"defs": "atts | defs"})

p1 = az.plot_violin(
    data.posterior["atts"], side="left", backend="bokeh", show=False, labeller=labeller
)
p2 = az.plot_violin(
    data.posterior["defs"],
    side="right",
    ax=p1,
    backend="bokeh",
    shade_kwargs={"color": "lightsalmon"},
    labeller=labeller,
)