Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Jan 21, 2026

When we are in a non-interactive environment (e.g. marimo export html), we fallback to a mime-renderer of png

Fixes #7816 (cc @AnirudhDagar)

@vercel
Copy link

vercel bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 21, 2026 9:05pm

Request Review

@mscolnick mscolnick changed the title improvement: fallback to png when in a non-interactive environment improvement: fallback to png for matplotlib when in a non-interactive environment Jan 21, 2026
@mscolnick mscolnick requested review from akshayka and manzt January 21, 2026 21:05
Copy link
Contributor

@AnirudhDagar AnirudhDagar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mscolnick for the fix. Looks good to me, left a very minor comment. Can also be safely ignored :p

return manager


def png_bytes(figure: Union[Figure, SubFigure, Axes]) -> bytes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typing includes Axes in the definition, but by the time these are called, Axes will always be converted to Figure here?

    if isinstance(figure, Axes):
        maybe_figure = figure.get_figure()
        assert maybe_figure is not None, "Axes object does not have a Figure"
        figure = maybe_figure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea it should only be Figure, SubFigure



class NonInteractiveMplHtml(Html):
def __init__(self, figure: Union[Figure, SubFigure, Axes]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@mscolnick mscolnick added the enhancement New feature or request label Jan 21, 2026
@mscolnick mscolnick merged commit d5499a1 into main Jan 21, 2026
46 of 55 checks passed
@mscolnick mscolnick deleted the ms/non-interactive-mpl branch January 21, 2026 23:22
@auxym
Copy link

auxym commented Jan 22, 2026

Thanks!

botterYosuke pushed a commit to botterYosuke/marimo that referenced this pull request Jan 22, 2026
botterYosuke pushed a commit to botterYosuke/marimo that referenced this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

marimo.mpl.interactive plots are blank when exported with marimo export html

5 participants