-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
plot save and plot show #16909
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
Please provide code for reproduction, preferably without extraneous data or dependencies, like it asks for in the template. |
very strange behavior in python 3.5 there is no error, but in subsequent ones there is an error, there was an error in my code, first you need to save it to a file and then show here the error playback. after switching to python 3.8 he started showing it to me |
ah, you are encountering a race condition. When you close the figure window
that came up from the `plt.show()` call, the figure starts to be destroyed.
But you then did a `fig.savefig()`. Put the savefig before the call to
`plt.show()`, or do your save from the interactive window.
…On Thu, Mar 26, 2020 at 5:37 PM big-vl ***@***.***> wrote:
import matplotlib.pyplot as plt
def plot():
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4])
ax.set(ylabel='some numbers')
plt.show()
fig.savefig('png/1.png')
for g in range(1,3):
plot()
very strange behavior in python 3.5 there is no error, but in subsequent
ones there is an error, there was an error in my code, first you need to
save it to a file and then show here the error playback. after switching to
python 3.8 he started showing it to me
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#16909 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6HXB6VLU6MR44Y6UZ3RJPDKJANCNFSM4LT3O6XA>
.
|
I wrote that you first need to save and then show why I thought that the error in the module and not everything worked for me in 3.5, thanks. maybe the developers will somehow check this problem :) |
Hi @big-vl ,have this prob solved? I encounter the same questions. when I save it to .svg format, this issue do not occur, however, when saving as png format, the program seems stuck at this save process. when I close the windows, it also gives me " invalid command name ." |
This should be fixed by #17391. |
I just ran over this bug, and I am glad this is already fixed and pushed into the next release. Until v3.2.2, I'll keep saving the figure before showing it. The only problem is that depending on the size of the figure saving can take some time, that's why I intended to save only after showing. Users might notice this delay. Is there any way to asynchronously save a figure other than the one described on https://gist.github.com/astrofrog/1453933? |
plt.show()
python v.: Python 3.8.2 (default, Feb 26 2020, 04:23:39)
matplotlib 3.2.1
dont save plot png.
The text was updated successfully, but these errors were encountered: