1

My OS X python installation is through homebrew. I then add python software using pip. I recently upgraded matplotlib from version 1.4.3 to 2.1.0 via pip install matplotlib --upgrade, and now matplotlib gives me this error when I try to make a basic plot:

In [1]: plt.plot(np.arange(10))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-a81699eb47e8> in <module>()
----> 1 plt.plot(np.arange(10))

/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, **kwargs)
   3227 @_autogen_docstring(Axes.plot)
   3228 def plot(*args, **kwargs):
-> 3229     ax = gca()
   3230     # Deprecated: allow callers to override the hold state
   3231     # by passing hold=True|False

/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in gca(**kwargs)
    957     matplotlib.figure.Figure.gca : The figure's gca method.
    958     """
--> 959     return gcf().gca(**kwargs)
    960
    961 # More ways of creating axes:

/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in gcf()
    586         return figManager.canvas.figure
    587     else:
--> 588         return figure()
    589
    590

/usr/local/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:

/usr/local/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)

I am not sure how to diagnose this. I do have a working Python 3 matplotlib however.

Is this actually a bug within version 2.1.0 of matplotlib?

  • I have exactly the same problem since upgrading to the current matplotlib version through pip (MacOSX Sierra, Python 2.7). – C.L. Oct 13 '17 at 3:28
4

This is an issue with matplotlib 2.1.0 on macOS. There is a bug which causes this due to some refactoring in the new release.

It will probably be fixed in a bug fix release soon, but you will have to downgrade if you need it working now.

To install old version: pip uninstall matplotlib && pip install matplotlib==2.0.2

Refs:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .