import plotly.graph_objects as go
import seaborn as sns
import maidr
# Load the penguins dataset
penguins = sns.load_dataset("penguins")
# Calculate average body mass by species
avg_mass = penguins.groupby("species")["body_mass_g"].mean()
# Create a bar plot showing the average body mass of penguins by species
fig = go.Figure(
data=[
go.Bar(
x=avg_mass.index.tolist(),
y=avg_mass.values.tolist(),
marker_color=["#4c72b0", "#55a868", "#c44e52"],
)
],
layout=go.Layout(
title="Average Body Mass of Penguins by Species",
xaxis=dict(title="Species"),
yaxis=dict(title="Body Mass (g)", tickformat=",.0f"),
),
)
maidr.show(fig) Plotly Accessible Plot Examples
Code examples showing how to make Plotly bar charts, histograms, line charts, box plots, heatmaps, and scatter plots accessible with py-maidr.
Plotly Examples
maidr also supports Plotly figures. If you already have data visualization code using plotly.graph_objects, you can make your plots accessible with maidr in just a few lines of code. For matplotlib and seaborn examples, see the Matplotlib / Seaborn Examples page.
Simply import the maidr package and pass your Plotly Figure to maidr.show(). maidr will automatically generate an accessible HTML version with sonification, braille, and keyboard navigation support.