streamlit.render_maidr

widget.streamlit.render_maidr(
    plot=None
    *
    height='content'
    width='stretch'
    tab_index=None
    use_cdn=None
    hover_mode=None
)

Draw an accessible MAIDR chart in a Streamlit app.

Parameters

Name Type Description Default
plot Any The plot to render – a matplotlib or seaborn artist, a Plotly Figure, a Bokeh figure or layout, or an Altair chart. None uses the current matplotlib figure, and warns: that figure is process-global, and Streamlit runs sessions on separate threads, so by the time it is rendered it may be another session’s. Pass the plot explicitly. None
height (int, {'content', 'stretch'}) Height of the embed. "content" lets Streamlit measure the chart, which is what keeps maidr’s braille and text panels visible when they open. "content"
width (int, {'content', 'stretch'}) Width of the embed. "stretch"
tab_index int or None Tab order of the frame, passed through to Streamlit. None is the browser default and is deliberate: an iframe’s contents already take part in sequential focus navigation, and maidr gives the chart inside its own tab stop, so a keyboard user tabs straight onto the chart. Passing 0 makes the frame itself a stop as well, which is one extra Tab before the chart – and on a Streamlit whose st.iframe does not take alt, that stop announces as “st.iframe” on every chart on the page. It is exposed for layouts that want a deterministic landing point, not because the chart needs it to be reachable. None
use_cdn bool, {"auto"}, or None Where the chart loads maidr.js from; see :func:maidr.render. Pass False for an air-gapped deployment. Prefer this argument over :func:maidr.set_use_cdn: the setter writes process-wide state, and Streamlit runs sessions on separate threads, so one session calling it changes what every other session renders. None
hover_mode ('pointermove', 'click', 'off') The chart’s starting value for the reader’s Hover Mode setting; see :func:maidr.render. None leaves maidr.js’s default. "pointermove"

Returns

Name Type Description
None Nothing is returned. The embed sends no data back, and handing back a Streamlit object would suggest an interactivity this does not have.

Notes

The frame is named after the chart – "<title>, accessible chart", or "Accessible chart" for an untitled one, as py-maidr names its own frames – on a Streamlit whose st.iframe takes alt. Older releases name every frame st.iframe, which cannot be overridden.

An unchanged chart reaches Streamlit as the same string on every rerun, so its frame is kept rather than reloaded, and a reader still in the chart keeps their place; the module notes have the measurement, what it does not cover, and why a Bokeh chart is the exception.

Examples

>>> import matplotlib.pyplot as plt
>>> from maidr.widget.streamlit import render_maidr
>>>
>>> fig, ax = plt.subplots()
>>> ax.bar(["a", "b"], [1, 2])
>>> render_maidr(ax)