You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
enable figures to be excluded from calls to show() #16377
Calling matplotlib.pyplot.show() displays all active figures. There are times this is not desirable, such as when some figure is still being developed. Of course, show() can be called for specific figures, but perhaps a user doesn't know that an undisplayed figure belongs to a class instance and these all get displayed when they call show() for their own plot.
It would be great if there was some attribute of a figure like figure.show_by_default, figure.implicit_show, or figure.exclude_from_show that could be set to stop these from popping up when plt.show() is called without arguments.
The behavior I want is achieved, in effect, after the figures I do not want to show have been shown once with a call to show() (i.e., I can still modify them and display them directly by accessing their canvasses, but they don't show up again with later calls to show). Is there a way I can make matplotlib think that show has already been called for specific figures, without having to actually displaying them with show?
In principle this is what plt.close(fig) is for. The problem is just that figures that are closed, cannot be reopenend as of now. #14024 (+ making sure every figure has a manager(?)) would make that possible though.
The ideal solution to the problem in the stackoverflow post would probably be not to use pyplot at all. But then it's hard to get the notebook to identify the canvas as something "showable".
Your example does work, but I also want to be able to display the plots via their canvasses (using ipympl) without calling show(), since in my actual problem the class I have returns a Box containing both ipywidgets and mpl canvasses.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
I am comfortable leaving this closed, directly creating the Figure s (with which ever canvsa you want) will create Figures that are unknown to pyplot and hence will not be implicated by plt.show().
Activity
anntzer commentedon Jan 30, 2020
I think this is basically a variant on #14024.
keatonb commentedon Jan 31, 2020
The behavior I want is achieved, in effect, after the figures I do not want to show have been shown once with a call to
show()(i.e., I can still modify them and display them directly by accessing their canvasses, but they don't show up again with later calls toshow). Is there a way I can make matplotlib think thatshowhas already been called for specific figures, without having to actually displaying them withshow?ImportanceOfBeingErnest commentedon Jan 31, 2020
In principle this is what
plt.close(fig)is for. The problem is just that figures that are closed, cannot be reopenend as of now.#14024 (+ making sure every figure has a manager(?)) would make that possible though.
The ideal solution to the problem in the stackoverflow post would probably be not to use pyplot at all. But then it's hard to get the notebook to identify the canvas as something "showable".
ImportanceOfBeingErnest commentedon Jan 31, 2020
Btw. you can attach the manager manually, so
should work?
keatonb commentedon Feb 3, 2020
Your example does work, but I also want to be able to display the plots via their canvasses (using ipympl) without calling
show(), since in my actual problem the class I have returns aBoxcontaining both ipywidgets and mpl canvasses.github-actions commentedon Jul 7, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
tacaswell commentedon Aug 7, 2023
I am comfortable leaving this closed, directly creating the
Figures (with which ever canvsa you want) will createFiguresthat are unknown topyplotand hence will not be implicated byplt.show().