-
Notifications
You must be signed in to change notification settings - Fork 882
improvement: fallback to png for matplotlib when in a non-interactive environment #7924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
AnirudhDagar
left a comment
There was a problem hiding this 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: |
There was a problem hiding this comment.
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_figureThere was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
|
Thanks! |
When we are in a non-interactive environment (e.g.
marimo export html), we fallback to a mime-renderer of pngFixes #7816 (cc @AnirudhDagar)