Skip to content
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

plt.show() #122

Closed
PaulSoderlind opened this issue Feb 24, 2022 · 2 comments
Closed

plt.show() #122

PaulSoderlind opened this issue Feb 24, 2022 · 2 comments

Comments

@PaulSoderlind
Copy link

plt = pyimport("matplotlib.pyplot") works well and it's easy to create plots.

However, with plt.show() the figure window has to be closed manually in order to use the REPL again. Instead with plt.show(;block=false) the figure window is blank and Julia hangs. (Julia 1.7.2, Win 10 64).

Example:

plt = pyimport("matplotlib.pyplot")
fig = plt.figure()
plt.plot(1:10)
plt.show()
@cjdoris
Copy link
Collaborator

cjdoris commented Feb 24, 2022

The behaviour with plt.show() is just how matplotlib behaves, even from the Python REPL.

To matplotlib in interactive mode, such as plt.show(block=false), you need to start an event loop to do the rendering in the background. See https://cjdoris.github.io/PythonCall.jl/stable/compat/#Event-loops.

@PaulSoderlind
Copy link
Author

it seems as if something like this works:

PythonCall.event_loop_on(:pyqt5)
plt.ion()

fig1 = plt.figure()
plt.plot(1:10)
plt.show()
...and then more plots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants