From andy at voelkel.us Thu Feb 6 20:41:32 2020 From: andy at voelkel.us (jandyman) Date: Thu, 6 Feb 2020 18:41:32 -0700 (MST) Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) Message-ID: <1581039692375-0.post@n5.nabble.com> 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 From tcaswell at gmail.com Fri Feb 7 11:31:55 2020 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 7 Feb 2020 11:31:55 -0500 Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: <1581039692375-0.post@n5.nabble.com> References: <1581039692375-0.post@n5.nabble.com> Message-ID: Jandyman, 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. Tom On Thu, Feb 6, 2020 at 8:41 PM jandyman 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: From andy at voelkel.us Fri Feb 7 12:09:14 2020 From: andy at voelkel.us (jandyman) Date: Fri, 7 Feb 2020 10:09:14 -0700 (MST) Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: References: <1581039692375-0.post@n5.nabble.com> Message-ID: <1581095354140-0.post@n5.nabble.com> Yes, I'm aware of the event loop issue. I thought that was the point of installing python "as a framework" and then using the macosx backend. I guess not. The description in the matplotlib docs was misleading. But thanks, I'll see if I can find a vs-code forum to ask this question. -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From pmhobson at gmail.com Fri Feb 7 12:19:36 2020 From: pmhobson at gmail.com (Paul Hobson) Date: Fri, 7 Feb 2020 09:19:36 -0800 Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: <1581095354140-0.post@n5.nabble.com> References: <1581039692375-0.post@n5.nabble.com> <1581095354140-0.post@n5.nabble.com> Message-ID: Hey Andy, Could you point us to where you feel the docs were misleading? Documentation is a difficult, on-going task. So specific and concrete feedback goes a long way towards keeping it useful. -p On Fri, Feb 7, 2020 at 9:09 AM jandyman wrote: > Yes, I'm aware of the event loop issue. I thought that was the point of > installing python "as a framework" and then using the macosx backend. I > guess not. The description in the matplotlib docs was misleading. > > But thanks, I'll see if I can find a vs-code forum to ask this question. > > > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at voelkel.us Fri Feb 7 12:43:55 2020 From: andy at voelkel.us (jandyman) Date: Fri, 7 Feb 2020 10:43:55 -0700 (MST) Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: References: <1581039692375-0.post@n5.nabble.com> <1581095354140-0.post@n5.nabble.com> Message-ID: <1581097435491-0.post@n5.nabble.com> At this link: https://matplotlib.org/faq/usage_faq.html#what-is-a-backend Under the section talking about what an interactive plot is, I see this: "Assuming you are running version 1.0.1 or higher, and you have an interactive backend installed and selected by default, you should see a plot, and your terminal prompt should also be active; you can type additional commands such as:" That sounds like exactly what I want. Then, at this link: https://matplotlib.org/3.1.0/faq/osx_framework.html There is a description of using macosx as a framework. So I thought I'd be good to go. As a general comment, I didn't really see a good description on the GUI main loop issue and how various systems deal with it. That would be really handy to understand when trying to troubleshoot this sort of thing -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From tcaswell at gmail.com Fri Feb 7 13:08:27 2020 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 7 Feb 2020 13:08:27 -0500 Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: <1581097435491-0.post@n5.nabble.com> References: <1581039692375-0.post@n5.nabble.com> <1581095354140-0.post@n5.nabble.com> <1581097435491-0.post@n5.nabble.com> Message-ID: That section assumes the prompt is either the plain python or IPython shell, both of which have machinery to hook up the input_hook below Matplotlib (which is required to have the figure to "be alive") and we install hooks to trigger re-draws when needed. In your case you are inside of an input loop in the debugger. For the figure to be live in that context something would need to be registered on the vscode side for the input hook. It is my understanding that "framework build" in this context refers to how the linking to the system libraries is done. Tom On Fri, Feb 7, 2020 at 12:44 PM jandyman wrote: > At this link: https://matplotlib.org/faq/usage_faq.html#what-is-a-backend > > Under the section talking about what an interactive plot is, I see this: > > "Assuming you are running version 1.0.1 or higher, and you have an > interactive backend installed and selected by default, you should see a > plot, and your terminal prompt should also be active; you can type > additional commands such as:" > > That sounds like exactly what I want. > > Then, at this link: https://matplotlib.org/3.1.0/faq/osx_framework.html > > There is a description of using macosx as a framework. So I thought I'd be > good to go. > > As a general comment, I didn't really see a good description on the GUI > main > loop issue and how various systems deal with it. That would be really handy > to understand when trying to troubleshoot this sort of thing > > > > -- > 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: From andy at voelkel.us Fri Feb 7 15:34:47 2020 From: andy at voelkel.us (jandyman) Date: Fri, 7 Feb 2020 13:34:47 -0700 (MST) Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: References: <1581039692375-0.post@n5.nabble.com> <1581095354140-0.post@n5.nabble.com> <1581097435491-0.post@n5.nabble.com> Message-ID: <1581107687615-0.post@n5.nabble.com> That is super handy information. It would be great if even those sentences were included in the docs at the first link I sent: https://matplotlib.org/faq/usage_faq.html#what-is-a-backend -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From petercohen8877 at gmail.com Sat Feb 8 16:13:52 2020 From: petercohen8877 at gmail.com (new_matplotlib_user) Date: Sat, 8 Feb 2020 14:13:52 -0700 (MST) Subject: [Matplotlib-users] Called with incorrect property value and Text input context does not respond to _valueForTIProperty message Message-ID: <1581196432325-0.post@n5.nabble.com> Hi, I am new to matplotlib. I installed Anacronda Navigator 1.9.7 on a Mac running Catalina 10.15.3 On a xterm, I went ipython and typed: [python] %matplotlib import matplotlib.pyplot as pat import numpy as np fig = plt.figure() [/python] Whenever I click on the figure window or some other windows on my desktop, I got the following messages. Could you please let me know how to get rid of them? Thanks In [32]: 2020-02-08 16:12:10.308 python[1036:20026] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2020-02-08 16:12:10.308 python[1036:20026] Text input context does not respond to _valueForTIProperty: 2020-02-08 16:12:10.309 python[1036:20026] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2020-02-08 16:12:10.309 python[1036:20026] Text input context does not respond to _valueForTIProperty: 2020-02-08 16:12:10.309 python[1036:20026] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2020-02-08 16:12:10.309 python[1036:20026] Text input context does not respond to _valueForTIProperty: 2020-02-08 16:12:10.309 python[1036:20026] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2020-02-08 16:12:10.309 python[1036:20026] Text input context does not respond to _valueForTIProperty: -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From selasley at icloud.com Sat Feb 8 17:18:42 2020 From: selasley at icloud.com (Scott Lasley) Date: Sat, 8 Feb 2020 17:18:42 -0500 Subject: [Matplotlib-users] Called with incorrect property value and Text input context does not respond to _valueForTIProperty message In-Reply-To: <1581196432325-0.post@n5.nabble.com> References: <1581196432325-0.post@n5.nabble.com> Message-ID: I ran Anaconda Navigator 1.9.7 under macOS 10.15.3 and I don't see the same behavior. I set up a snowflakes environment with python 3.7 as described in the Navigator getting started docs https://docs.anaconda.com/anaconda/navigator/getting-started/ then installed matplotlib and ipython and ran the commands you listed after clicking on the arrow next to the environment name and selecting Open Terminal $ python --version Python 3.7.6 $ ipython3 Python 3.7.6 (default, Jan 8 2020, 13:42:34) Type 'copyright', 'credits' or 'license' for more information IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: %matplotlib Using matplotlib backend: MacOSX In [2]: import matplotlib.pyplot as plt In [3]: import numpy In [4]: plt.figure() Out[4]:
Clicking in the plot window or any other window does not produce the messages you are seeing. When I created the snowflakes environment the default python version selected was 2.7. Make sure you are using python 3.6 or higher in your environment - https://matplotlib.org/users/installing.html#dependencies Hth, Scott > On Feb 8, 2020, at 4:13 PM, new_matplotlib_user wrote: > > Hi, I am new to matplotlib. I installed Anacronda Navigator 1.9.7 on a Mac > running Catalina 10.15.3 > > On a xterm, I went ipython and typed: > > [python] > %matplotlib > import matplotlib.pyplot as pat > import numpy as np > fig = plt.figure() > [/python] > > Whenever I click on the figure window or some other windows on my desktop, I > got the following messages. > Could you please let me know how to get rid of them? Thanks > > > In [32]: 2020-02-08 16:12:10.308 python[1036:20026] > imkxpc_getApplicationProperty:reply: called with incorrect property value 4, > bailing. > 2020-02-08 16:12:10.308 python[1036:20026] Text input context does not > respond to _valueForTIProperty: > 2020-02-08 16:12:10.309 python[1036:20026] > imkxpc_getApplicationProperty:reply: called with incorrect property value 4, > bailing. > 2020-02-08 16:12:10.309 python[1036:20026] Text input context does not > respond to _valueForTIProperty: > 2020-02-08 16:12:10.309 python[1036:20026] > imkxpc_getApplicationProperty:reply: called with incorrect property value 4, > bailing. > 2020-02-08 16:12:10.309 python[1036:20026] Text input context does not > respond to _valueForTIProperty: > 2020-02-08 16:12:10.309 python[1036:20026] > imkxpc_getApplicationProperty:reply: called with incorrect property value 4, > bailing. > 2020-02-08 16:12:10.309 python[1036:20026] Text input context does not > respond to _valueForTIProperty: > > > > > -- > 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 From petercohen8877 at gmail.com Sat Feb 8 23:10:19 2020 From: petercohen8877 at gmail.com (new_matplotlib_user) Date: Sat, 8 Feb 2020 21:10:19 -0700 (MST) Subject: [Matplotlib-users] Called with incorrect property value and Text input context does not respond to _valueForTIProperty message In-Reply-To: <1581196432325-0.post@n5.nabble.com> References: <1581196432325-0.post@n5.nabble.com> Message-ID: <1581221419402-0.post@n5.nabble.com> Hi Scott, I checked the python and ipython versions. They they are same as yours. When I typed plt.figure(), a figure window showed up in front of my xterm window. When I moved the cursor to title of the figure window, those messages showed up. Clicking the title of the xterm window also caused those messages to show up. -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From newville at cars.uchicago.edu Sun Feb 9 11:55:38 2020 From: newville at cars.uchicago.edu (Matt Newville) Date: Sun, 9 Feb 2020 10:55:38 -0600 Subject: [Matplotlib-users] Can't get interactive plots working on OSX (Catalina) In-Reply-To: <1581039692375-0.post@n5.nabble.com> References: <1581039692375-0.post@n5.nabble.com> Message-ID: Hi Jandyman, On Thu, Feb 6, 2020 at 7:41 PM jandyman 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 also find the 'macosx' backend to be challenging for interactive work. It seems you have to keep hitting return in the main python REPL for the 'macosx' event loop to process. The other backends do not need this. In particular, the 'qt5agg' and 'tkagg' backends will do what (I think) you are looking for: `pyplot.ion()` will make `pyplot.plot()` draw to the screen immediately with a responsive plot window and not block the REPL. The 'wxagg' backend should be able to do this, but it appears that `pyplot.ion()` does not actually work as it does for 'qt5agg' and 'tkagg' - I don't know why that it is. You might find `wxmplot` (https://newville.github.io/wxmplot/ -- I am the author of this) useful for interactive work from the Python REPL (or from IPython for that matter). With this, you would do something like: >>> import numpy as np >>> from wxmplot.interactive import plot >>> x = np.linspace(0, 20, 100) >>> pd = plot(x, np.sin(x)) This will immediately bring up a separate plot window and returning control to the REPL. The window is highly interactive: you can zoom in, save images, and alter nearly every aspect of the plot (colors, themes, linewidths, styles, markers, text labels, margins, legend display, log scales, etc) from a configuration panel. You can also easily plot to multiple window frames, say with >>> pd2 = plot(x, np.cos(x), win=2) Of course, not every aspect of matplotlib is exposed in `wxmplot`. The return value from `plot` has a `panel.axes` attribute that is the `matplotlib.axes`, which can be used for more complicated plot components. There is also a `wxmplot.interactive.imshow` for showing false-color images from 2-d arrays that also has many interactive options (color tables, contrast, smoothing, etc). `wxmplot` can be installed with `pip install wxmplot`. There is a nasty problem with Anaconda Python on MacOS that `python` is not a framework build and so the wxPython module cannot draw to the screen, and trying to do so exits python. Instead, one needs to use `pythonw` (from the `python.app` conda package) to use wxPython with Anaconda Python on MacOS. I do not know why this is. This is merely irritating for running scripts or applications, but is particularly problematic when using IDEs such as Spyder or Idle, as they embed a Python interpreter that has been launched with `python`, not `pythonw`. For me, VSCode works fine as it uses python from Python.org which does not have this problem. Hope that helps, --Matt Newville -------------- next part -------------- An HTML attachment was scrubbed... URL: From apuroopa.rao1 at gmail.com Thu Feb 20 02:42:14 2020 From: apuroopa.rao1 at gmail.com (apu) Date: Thu, 20 Feb 2020 07:42:14 -0000 Subject: [Matplotlib-users] Connect plot in Contourf when there are missing values(nan) Message-ID: <1582184535596-0.post@n5.nabble.com> I am plotting x, y, z values using contourf plots. However I have some missing z values (nan). All these regions are shown as blanks and the graph looks diconnected. Is there a way for the plot to have connected gaps? Plotly has an option to connect gaps with smooth transitions? https://plot.ly/python/contour-plots/#connect-the-gaps-between-none-values-in-the-z-matrix Do we have an equivalent of this in matlotlib contourf plots? -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html