import matplotlib.pyplot as plt
import seaborn as sns
# Just import maidr package
import maidr
# Load the penguins dataset
= sns.load_dataset("penguins")
penguins
# Create a bar plot showing the average body mass of penguins by species
=(6, 6))
plt.figure(figsize
# Assign the plot to a variable
= sns.barplot(
bar_plot ="species", y="body_mass_g", data=penguins, errorbar="sd", palette="Blues_d"
x
)"Average Body Mass of Penguins by Species")
plt.title("Species")
plt.xlabel("Body Mass (g)")
plt.ylabel(
# plt.show()
# Use maidr.show() to display your plot
maidr.show(bar_plot)
Example Gallery
Example Gallery
Making accessible data representation with maidr is easy and straightforward. If you already have data visualization code using matplotlib or seaborn, you can make your plots accessible with maidr in just a few lines of code.
Simply import the maidr
package and use the maidr.show()
function to display your plots. maidr will automatically generate accessible versions of your plots in your default browser. You can then interact with the accessible versions using keyboard shortcuts (refer to Table 1).
Bar Plot
Histogram
import matplotlib.pyplot as plt
import seaborn as sns
import maidr
# Load the Iris dataset
= sns.load_dataset("iris")
iris
# Select the petal lengths
= iris["petal_length"]
petal_lengths
# Plot a histogram of the petal lengths
=(6, 6))
plt.figure(figsize
= sns.histplot(petal_lengths, kde=True, color="blue", binwidth=0.5)
hist_plot
"Petal Lengths in Iris Dataset")
plt.title("Petal Length (cm)")
plt.xlabel("Frequency")
plt.ylabel(
# plt.show()
maidr.show(hist_plot)
Line Plot
import matplotlib.pyplot as plt
import seaborn as sns
import maidr
# Load the 'tips' dataset from seaborn
= sns.load_dataset("tips")
tips
# Choose a specific subset of the dataset (e.g., data for 'Thursday')
= tips[tips["day"] == "Thur"]
subset_data
# Create a line plot
=(6, 6))
plt.figure(figsize= sns.lineplot(
line_plot =subset_data,
data="total_bill",
x="tip",
y=True,
markers="day",
style=False,
legend
)"Tips vs Total Bill (Thursday)")
plt.title("Total Bill")
plt.xlabel("Tip")
plt.ylabel(
# plt.show()
maidr.show(line_plot)
Heat Map
import matplotlib.pyplot as plt
import seaborn as sns
import maidr
# Load an example dataset from seaborn
= sns.load_dataset("glue").pivot(index="Model", columns="Task", values="Score")
glue
# Plot a heatmap
=(8, 8))
plt.figure(figsize= sns.heatmap(glue, annot=True, fill_label="Score")
heatmap "Model Scores by Task")
plt.title(
# Show the plot
# plt.show()
maidr.show(heatmap)
Box Plot
- Note: Visual highlight feature has not been implemented in the box plot yet.
import matplotlib.pyplot as plt
import seaborn as sns
from seaborn import load_dataset
import maidr
# Load the iris dataset
= load_dataset("iris")
iris
# Create the horizontal boxplot
= sns.boxplot(x="petal_length", y="species", data=iris, orient="h")
horz_box_plot "Species")
plt.ylabel("Petal Length")
plt.xlabel("Petal Length by Species from Iris Dataset")
plt.title(# plt.show()
# Show the plot
maidr.show(horz_box_plot)
Scatter Plot
import matplotlib.pyplot as plt
import seaborn as sns
import maidr
# Create a scatter plot
= sns.scatterplot(
scatter_plot =iris, x="sepal_length", y="sepal_width", hue="species"
data
)
# Adding title and labels (optional)
"Iris Sepal Length vs Sepal Width")
plt.title("Sepal Length")
plt.xlabel("Sepal Width")
plt.ylabel(
# Show the plot
# plt.show()
maidr.show(scatter_plot)
Reactive Dashboard
Shiny
Check out a reactive Shiny dashboard example with maidr and its source code is available on GitHub.
Streamlit
Check out this Streamlit dashboard with maidr, and its source code is available on GitHub.
* Note: `Streamlit` framework has some "Unlabeled 0 Button" which does not have to do with our maidr package. This issue needs to be addressed by the `Streamlit` team.
Interactive Computing (Jupyter Notebooks, Jupyter Labs, Google Colab)
Check out this interactive notebook in Google Colab.
Other Examples
We provide some example code for using py-maidr with matplotlib, seaborn, Jupyter Notebook, Quarto, Shiny, and Streamlit.
Keyboard Shortcuts and Controls
To interact with the plots using maidr, follow these steps:
- Press the Tab key to focus on the plot element.
- Use the arrow keys to move around the plot.
- Press B to toggle Braille mode.
- Press T to toggle Text mode.
- Press S to toggle Sonification (tones) mode.
- Press R to toggle Review mode.
Below is a detailed list of keyboard shortcuts for various functions:
Function | Windows and Linux Key | Mac Key |
---|---|---|
Toggle Braille Mode | b | b |
Toggle Text Mode | t | t |
Toggle Sonification Mode | s | s |
Toggle Review Mode | r | r |
Move around plot | Arrow keys | Arrow keys |
Go to the very left right up down | Ctrl + Arrow key | CMD + Arrow key |
Select the first element | Ctrl + Home | CMD + Home |
Select the last element | Ctrl + End | CMD + End |
Repeat current sound | Space | Space |
Auto-play outward in direction of arrow | Ctrl + Shift + Arrow key | CMD + Shift + Arrow key |
Auto-play inward in direction of arrow | Alt + Shift + Arrow key | Option + Shift + Arrow key |
Stop Auto-play | Ctrl | Ctrl |
Auto-play speed up | Period (.) | Period (.) |
Auto-play speed down | Comma (,) | Comma (,) |
Auto-play speed reset | Slash (/) | Slash (/) |
Check label for the title of current plot | l t | l t |
Check label for the x axis of current plot | l x | l x |
Check label for the y axis of current plot | l y | l y |
Check label for the fill (z) axis of current plot | l f | l f |
Check label for the subtitle of current plot | l s | l s |
Check label for the caption of current plot | l c | l c |
Toggle AI Chat View | Ctrl + Shift + / | Option + Shift + / |
Copy last chat message in AI Chat View | Alt + Shift + C | Option + Shift + C |
Copy full chat history in AI Chat View | Alt + Shift + A | Option + Shift + A |
Demo Video
Bug Report
If you encounter a bug, have usage questions, or want to share ideas to make this package better, please feel free to file an issue.
Code of Conduct
Please note that the maidr project is released with a contributor code of conduct.
By participating in this project you agree to abide by its terms.
📄 License
maidr is licensed under the GPL3 license.
🏛️ Governance
This project is primarily maintained by JooYoung Seo and Saairam Venkatesh. Other authors may occasionally assist with some of these duties.