New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard shortcuts to close the figure are not active on OS X with the backend MacOSX #4372
Comments
attn @mdehoon |
Do you have other keys mapped to actions? Do they work? I wonder if this is On Thu, Apr 23, 2015 at 10:51 AM, Thomas A Caswell <notifications@github.com
|
If I put
then the figure closes if I click on the figure (to make it active) and press 'q'. |
I think this is a terminal/plot focus issue. When I click on the plot, both my terminal and the figure are active (screenshot). I have tried other keymaps. They do not work with the MacOSX backend but do work with the Qt4Agg backend. Is this problem unique to my system? I see this behavior even under a virtualenv after activating and running |
The screenshot suggests that your Python is not installed as a framework. |
This issue can be close if it's local to my machine. I have solved it by switching backends. (I'm using Anaconda) |
Let's not close this issue yet. I'd like to find out why matplotlib didn't notice that Python was not installed as a framework. |
@scottsievert Can you have a look in your pyconfig.h to see if WITH_NEXT_FRAMEWORK is defined? It should contain the following line: >>> import sys
>>> sys.prefix
'/Library/Frameworks/Python.framework/Versions/2.7' then pyconfig.h will be in the directory sys.prefix + /include/python2.7. |
In [1]: import sys
In [2]: sys.prefix
Out[2]: '/Users/scott/anaconda' The relevant part of pyconfig.h: /* Define if you want to produce an OpenStep/Rhapsody framework (shared
library plus accessory files). */
/* #undef WITH_NEXT_FRAMEWORK */ I just installed a fresh version of Anaconda. It worked after that fresh install. |
OK thanks. Indeed your Python is not installed as a framework. Matplotlib should have noticed that when it was compiled. Did you compile matplotlib yourself, or did you use a precompiled matplotlib? |
I used the version of mpl that came with Anaconda. I installed Anaconda long before this bug appeared, and the only real changes I can think of was that I upgraded anaconda (using conda upgrade anaconda) and developed a package which required I play with pandoc/markdown. |
Aha, got it! This is perhaps a different issue -- it is present under a freshly installed version of anaconda. I switched Python shells from IPython to ptipython. My keybinding 'q' works only when I use IPython. To show that, I have run the script under different python interpreters (and get different behaviors!): from __future__ import division
from numpy import sin, linspace, pi
from matplotlib.pyplot import figure, plot, show
t = linspace(0, 2*pi)
y = sin(t)
figure()
plot(t, y)
show() To be clear, while I was running this, by backend was MacOSX on OSX 10.10 under a freshly installed Anaconda. Under python, ptpython and ptipython, the keymap |
@scottsievert I have added a run-time check to the MacOSX backend to make sure Python is installed as a framework (see the pull request). On Python2, the same check is also available as part of the MacOS module, which is part of the Python standard library. Could you try the following with python/ipython/ptpython/ptipython: >>> import MacOS
>>> MacOS.WMAvailable() This should return True if python is installed as a framework, and False otherwise. |
|
Thanks! This was fixed by pull request #4452 . The new code effectively does the same as WMAvailable(). |
Closed by #4452 |
Issue
I have a special key (
q
) mapped to close the current figure. Using matplotlib 1.4.3 I can not close the current figure with this keymap and under the backend MacOSX. Specifically when I press theq
key the keypress is sent to the shell instead.I am currently on OSX Yosemite. My quick fix was to choose a different backed, Qt4Agg.
In my matplotlibrc file I have
keymap.quit : q
Related issues
I am currently unsure if this has been fixed in the bleeding edge version of mpl. I have tested mpl-1.4.3 under a virtualenv and get the same results.
The text was updated successfully, but these errors were encountered: