[Matplotlib-users] Can't get interactive plots working on OSX (Catalina)

jandyman andy at voelkel.us
Thu Feb 6 20:41:32 EST 2020


Hi,

I've spent several hours trying to figure out how to get interactive plots
to work on MacOS Catalina (plots which don't block program execution). I got
fairly excited when I found instructions in the Matplotlib docs for using
python as a framework and then using the macosx backend, but it doesn't seem
to help. I'm operating in debug mode from Visual Studio Code, which
otherwise seems to work well. Here's the code:

import matplotlib.pyplot as plt
import matplotlib
import numpy as np

matplotlib.use("macosx")
plt.ion()
x = np.linspace(0, 20, 100)  # Create a list of evenly-spaced numbers over
the range
plt.plot(x, np.sin(x))       # Plot the sine of each x point
plt.show() 
# put a breakpoint on this next line 
y = 5

If I omit the call to plt.ion(), I get a plot that blocks program execution
until I close the plot window, so I don't hit the breakpoint until the plot
is gone. If I leave the call to plot.ion() in, I hit the breakpoint, but no
plot is shown.

Does anyone know if is possible to get this to work, and if so, how? I've
got this sort of thing to work before with Spyder, but it is hinky, and I've
got other issues with Spyder. I'm just chasing the sort of user experience I
used to have with Matlab, only with Python, which I like better as a
language.

A lot of folks seems to use Jupyter for this sort of thing, and Jupyter is
great for what it does, but it isn't what I'm trying to do.



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html


More information about the Matplotlib-users mailing list