-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Create a sibling to pyplot.plot that garuntees the creation of a new figure #18248
Comments
This special cases |
"Create a new figure when using a plotting command" is what the
That's exactly how pyplot is meant to work: Do everything on the active figure. For convenience, a new figure is created if there is no active figure.
That's a misconception. Every cell creates a new figure. Personally, I find that more intuitive because a cell is a "unit of thought", but I cannot speak for expectations of others.
|
That is a much better way of putting it. In fact I think that is really what I want, but I assumed it wouldn't be possible. Though given that the inline backend manages to do as much I imagine the the ipympl backend may also be able to. I will close this and potentially open an issue there to discuss how that might be possible to implement. Thanks! |
This is not quite right either. Every cell closes all open figures. This might seem like a meaningless distinction, but if you were to call |
@ianhi See matplotlib/ipympl#171 for a long discussion of what is going on and why it is a bit subtle to get right. |
Problem
pyplot.plot
will only create a new figure if there are no active figures. Thus when I am in a jupyter notebook with the ipympl backend I often write the following snippet:There are two issues, one of convenience and one of user confusion:
plt.figure
every time I want a new figure to show up.plt.plot
in a cell will always create a new figureMy examples are both jupyter centric as that is my primary environment, but it feels as though the proposed solutions would belong in matplotlib proper rather than a backend.
Proposed Solution
Create two new functions in pyplot:
plot_figure
andplot_subplots
that are guaranteed to create a new figure and otherwise act likepyplot.plot
. Below are two incomplete implementations that I have been using.Additional context and prior art
Something that would be nice but probably is not technically feasible is a matplotlib figure that is associated with a specific juptyer cell. The proposed solution approximates such a figure per cell behavior. I think this desire is residual from my having "grown up" as it were using the inline backend. There are now features that I want from the interactive backend, but old habits like expecting
plt.plot
to just create a figure die hard.The text was updated successfully, but these errors were encountered: