Skip to content

Qt5 backend doesn't work with Qt 5.3 #3623

Closed
@jenshnielsen

Description

@jenshnielsen

I have previously had the Qt5 backend working with mpl 1.4.0 however It seems broken to me now.
Trying to do a simple plot with plt.plot results in

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-bf7ca2578bf6> in <module>()
----> 1 plt.plot(range(100))

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/pyplot.py in plot(*args, **kwargs)
   3089 @_autogen_docstring(Axes.plot)
   3090 def plot(*args, **kwargs):
-> 3091     ax = gca()
   3092     # allow callers to override the hold state by passing hold=True|False
   3093     washold = ax.ishold()

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/pyplot.py in gca(**kwargs)
    826     matplotlib.figure.Figure.gca : The figure's gca method.
    827     """
--> 828     ax =  gcf().gca(**kwargs)
    829     return ax
    830

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/pyplot.py in gcf()
    460         return figManager.canvas.figure
    461     else:
--> 462         return figure()
    463
    464 fignum_exists = _pylab_helpers.Gcf.has_fignum

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/pyplot.py in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, **kwargs)
    433                                         frameon=frameon,
    434                                         FigureClass=FigureClass,
--> 435                                         **kwargs)
    436
    437         if figLabel:

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/backends/backend_qt5agg.py in new_figure_manager(num, *args, **kwargs)
     46     FigureClass = kwargs.pop('FigureClass', Figure)
     47     thisFig = FigureClass(*args, **kwargs)
---> 48     return new_figure_manager_given_figure(num, thisFig)
     49
     50

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/backends/backend_qt5agg.py in new_figure_manager_given_figure(num, figure)
     53     Create a new figure manager instance for the given figure.
     54     """
---> 55     canvas = FigureCanvasQTAgg(figure)
     56     return FigureManagerQT(canvas, num)
     57

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/backends/backend_qt5agg.py in __init__(self, figure)
    179         if DEBUG:
    180             print('FigureCanvasQtAgg: ', figure)
--> 181         FigureCanvasQT.__init__(self, figure)
    182         FigureCanvasAgg.__init__(self, figure)
    183         self._drawRect = None

/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib-1.5.x-py3.4-macosx-10.9-x86_64.egg/matplotlib/backends/backend_qt5.py in __init__(self, figure)
    235         # __init__() takes exactly 2 arguments (1 given) on QWidget
    236         # PyQt5
--> 237         super(FigureCanvasQT, self).__init__(figure=figure)
    238         self.figure = figure
    239         self.setMouseTracking(True)

TypeError: 'figure' is an unknown keyword argument

This is naturally because QtWidgets.QWidget does not take a figure keyword argument. Removing the kwarg seems to resolve the issue with a simple figure. But I am unsure if the intention of this line is to call init on QtWidgets.QWidget or FigureCanvasBase which does take that kwarg.

Since this has working before I guess that this is somehow related to me upgrading to Qt5.3.
The traceback above is from the master branch but the same seems to happen with 1.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions