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

Thomas Caswell tcaswell at gmail.com
Fri Feb 7 11:31:55 EST 2020


 The short answer: something has to run the GUI event loop while the prompt
is waiting for user input.  This is typically called an "input hook".

For a long answer see https://github.com/matplotlib/matplotlib/pull/4779 .

Unfortunately I am not familiar enough with vscode's debug mode to provide
any guidance on how to configure it in that context.


On Thu, Feb 6, 2020 at 8:41 PM jandyman <andy at voelkel.us> wrote:

> 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
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users

Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200207/2ece5d83/attachment.html>

More information about the Matplotlib-users mailing list