# pycall matplotlib non-blocking plot?

**URL:** <https://discourse.julialang.org/t/pycall-matplotlib-non-blocking-plot/22876>\
**Category:** Visualization\
**Created:** [April 7, 2019, 2:54pm UTC](https://discourse.julialang.org/t/pycall-matplotlib-non-blocking-plot/22876 "2019-04-07T14:54:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KestutisMa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kestutisma/32/7835_2.png) [@KestutisMa](https://discourse.julialang.org/u/KestutisMa)\
**Post date:** [April 7, 2019, 2:54pm UTC](https://discourse.julialang.org/t/pycall-matplotlib-non-blocking-plot/22876/1 "2019-04-07T14:54:37Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [April 7, 2019, 3:13pm UTC](https://discourse.julialang.org/t/pycall-matplotlib-non-blocking-plot/22876/2 "2019-04-07T15:13:53Z")

</div>

I think you need to do

```julia
plt.ion()

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 7, 2019, 3:52pm UTC](https://discourse.julialang.org/t/pycall-matplotlib-non-blocking-plot/22876/3 "2019-04-07T15:52:10Z")

</div>

> [@KestutisMa](#):
>
> Could it be possible to pycall interactive plot without blocking GUI or Julia?

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”)`

---

<div class="post-metadata">

**Author:** ![KestutisMa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kestutisma/32/7835_2.png) [@KestutisMa](https://discourse.julialang.org/u/KestutisMa)\
**Post date:** [April 7, 2019, 5:08pm UTC](https://discourse.julialang.org/t/pycall-matplotlib-non-blocking-plot/22876/4 "2019-04-07T17:08:21Z")

</div>

Thanks for reply, I just solved problem using [GitHub - JuliaPy/PyCall.jl: Package to call Python functions from the Julia language](https://github.com/JuliaPy/PyCall.jl#gui-event-loops) 🙂
