Repository navigation
Closed
Milestone
Description
Bug report
Bug summary
matplotlib 2.1.0 from ipython with backend macosx ->
need _BackendMac, got FigureManagerMac
Code for reproduction
# Paste your code here
#
#
import sys
import matplotlib as mpl
import matplotlib.pyplot as pl
print "matplotlib.__version__ :", mpl.__version__
print "pl.rcParams['backend'] :", pl.rcParams["backend"]
print "sys.version :", sys.version
# -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python
# a framework build ? https://matplotlib.org/faq/osx_framework.html
fig, ax = pl.subplots()Actual outcome
# If applicable, paste the console output here
#
#
IPython
matplotlib.__version__ : 2.1.0
pl.rcParams['backend'] : MacOSX
sys.version : 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/bz/py/etc/plot/mpl210.py in <module>()
19
20
---> 21 fig, ax = pl.subplots()
22
/Library/Python/2.7/site-packages/matplotlib/pyplot.pyc in subplots(nrows, ncols, sharex, sharey, squeeze, subplot_kw, gridspec_kw, **fig_kw)
1177 subplot
1178 """
-> 1179 fig = figure(**fig_kw)
1180 axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
1181 squeeze=squeeze, subplot_kw=subplot_kw,
/Library/Python/2.7/site-packages/matplotlib/pyplot.pyc in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
554 # FigureManager base class.
555 if matplotlib.is_interactive():
--> 556 draw_if_interactive()
557
558 if _INSTALL_FIG_OBSERVER:
/Library/Python/2.7/site-packages/matplotlib/backend_bases.py in draw_if_interactive(cls)
183 manager = Gcf.get_active()
184 if manager:
--> 185 cls.trigger_manager_draw(manager)
186
187 @classmethod
TypeError: unbound method trigger_manager_draw() must be called with _BackendMac instance as first argument (got FigureManagerMac instance instead)
Expected outcome
used to work: 2.0.2
Matplotlib version
- Operating system: 10.8.3
- Matplotlib version: 2.1.0
- Matplotlib backend (
print(matplotlib.get_backend())): macosx - Python version: 2.7.14
- Jupyter version (if applicable):
- Other libraries:
pip install --upgrade --user matplotlib
python.org python-2.7.14-macosx10.6.pkg
Sorry if this a "framework build issue" which I don't understand, but 2.0.2 worked.
Also, kudos for the improved doc in 2.1 !
Metadata
Metadata
Assignees
Labels
No labels
Activity
denis-bz commentedon Oct 10, 2017
Sorry sorry:
ipython --pylab-> no TypeError _BackendMac,then
pl.show()is necessary afterpl.draw().thanks, cheers
-- denis
WeatherGod commentedon Oct 10, 2017
Just as a note, the
ipython --pylabincantation is highly discouraged, and has been for several years now, because it causes imports to happen that does not appear in the session history, which leads to irreproducibility.What do you mean by "pl.show() is necessary after pl.draw()"? Do you mean that you get an error, or that nothing happens until you do a pl.show()?
As for this traceback, I think we should still investigate it in order to figure out if we have some deeper problem.
denis-bz commentedon Oct 10, 2017
jklymak commentedon Oct 10, 2017
Can't reproduce using conda py2.7:
A plot doesn't show until I execute
pl.show().WeatherGod commentedon Oct 10, 2017
We aren't ipython, so we don't have any say. However, my understanding is that all it does is call
from pylab import *. If you put that in first when you start up an ipython session, it should be equivalent toipython --pylab. The point is that "explicit is better than implicit", by having the user specify the pylab import properly, rather than having ipython do it automatically for you.As for the plot not showing until you do
pl.show(), that is a matter of whether or not the interactive mode is turned on or not. We ship matplotlib with it turned off by default, so the figure doesn't show until you explicitly saypl.show(). However, this default behavior can be overridden in your matplotlibrc file. Did you change computers or something that would have caused you to have a new matplotlibrc file?anntzer commentedon Oct 10, 2017
xref #9347
my bad
denis-bz commentedon Oct 10, 2017
denis-bz commentedon Oct 11, 2017
A further comment: there seem to be 3 related questions:
has anyone been able to reproduce this in python or ipython ?
ipython --pylablead totrigger_manager_draw( _BackendMac )?is_interactive / draw / show( block= )work in mpl ?quite a few old Q+A on SO on this.
tuanbui53 commentedon Oct 19, 2017
On my macOS High Sierra, I upgraded to matplotlib 2.1.0.
In [15]: matplotlib.__version__ Out[15]: '2.1.0'I start with command: ipython --pylab
Then when I type:
In [1]: figure()This gives the error:
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 figure()
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.pyc in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
554 # FigureManager base class.
555 if matplotlib.is_interactive():
--> 556 draw_if_interactive()
557
558 if _INSTALL_FIG_OBSERVER:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/utils/decorators.pyc in wrapper(*args, **kw)
41 def wrapper(*args,**kw):
42 wrapper.called = False
---> 43 out = func(*args,**kw)
44 wrapper.called = True
45 return out
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in draw_if_interactive(cls)
183 manager = Gcf.get_active()
184 if manager:
--> 185 cls.trigger_manager_draw(manager)
186
187 @classmethod
TypeError: unbound method trigger_manager_draw() must be called with _BackendMac instance as first argument (got FigureManagerMac instance instead)`
leewalsh commentedon Nov 1, 2017
Just to clarify: this bug is not caused by the
pylaboption, but rather byinteractive(as in #9366 and #9489). So an easier workaround is to turn interactive off withplt.interactive(False):And an aside for those of us who like some auto import and interactive plots: you can have your cake and eat it too by setting
InteractiveShellApp.pylab_import_alltoFalse. This will load your matplotlib backend and set up interactive figures, and will import these modules:... but will skip the
*imports:To get this, add this to your
ipython_config.py: