pycall matplotlib non-blocking plot?

#1

Hello, I am wondering how to do non-blocking plot:
using PyCall; plt = pyimport("matplotlib.pyplot"); plt.plot([1,2]); plt.show() shows plot window, but Julia is blocked, till I close plot window;
plt.show(block = false) does not block Julia, but does block plot GUI window, and I need to do plt.pause(5) to update plot window and use its GUI buttons (to process event loop) and during that Julia REPL is blocked, then after 5 s GUI is again blocked.
Could it be possible to pycall interactive plot without blocking GUI or Julia? In Python plt.show(block = false) does work for this. Maybe use of multiple threads? P.S. @async doesn’t help.

I use pycall to call matplotlib because it has quite low compile latency (Julia v1.1).

#2

I think you need to do

plt.ion()
#3

Use the PyPlot package (a thin wrapper around PyCall and matplotlib), which provides a non-blocking interactive GUI via a background task. It should be nicer to use from Julia than directly doing pyimport(“matplotlib.pyplot”)

#4

Thanks for reply, I just solved problem using https://github.com/JuliaPy/PyCall.jl#gui-event-loops :slight_smile: