-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Add _repr_svg_
etc to Figure
#25846
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
Comments
Hmm, it seems like this works (as in Figures show up inline when returned)... Although it returns a html representation. So possibly we may consider adding other formats? A bit information about the possible |
|
This comment was marked as off-topic.
This comment was marked as off-topic.
As noted above,
So it seems like adding more of these will almost certainly make the repr slower. |
Anything we do in this space needs to be coordinated with IPython to not cause conflicts. |
Problem
Jupyter Qt Console, Spyder and probably Jupyter Notebooks and others can display enriched formats for objects.
It would be convenient if
Figure
(and possibly other Artists where possible) returned these.Note that this is different from
%matplotlib inline
in the sense that the object returns its own representation, not that it plots inline. Although from some perspective it is the same thing. However, I'd like to be able to do something likeand then
fig
is shown inline.And to be even more specific. I have a class where I would like to be able to return different "views" of it in this way. The class already have a
_repr_svg_
-method (which returns an SVG generated from Matplotlib), but I would like to have properties that returns an object with a different_repr_svg_
. One way is to use a simple wrapper, similar to:https://stackoverflow.com/questions/72613209/displaying-a-matplotlib-figure-from-a-custom-class-in-jupyter-notebook (although a bit more code is required), but maybe we would like to support this directly?
Related to #16782
Proposed solution
Add
_repr_svg_
,_repr_png_
, and maybe some more methods (possibly_repr_mimebundle_
). The main question is when these are called and if it brings any performance penalties for people not relying on this?Something like this will do:
but this should be discussed before any PR is created.
There are a few methods like this already. Colors can draw themselves and I now see that there is a
_repr_html_
forFigure
. As well as something for a font entry.The text was updated successfully, but these errors were encountered: