当我尝试通过以下代码绘制一个交互式图表时:
import matplotlib.pyplot as plt
import PyQt5
%matplotlib qt
...
plt.plot(a_list,b_list)
plt.show()
我收到以下错误信息:
--------------------------------------------------------------------------- TypeError Traceback (most recent call
last) <ipython-input-49-187dd4fead7a> in <module>()
----> 1 plt.plot(parameters['eng_list'],np.real(conductivity))
2 plt.plot(parameters['eng_list'],np.imag(conductivity))
3 plt.show()
C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py in plot(*args,
**kwargs) 3305 @_autogen_docstring(Axes.plot) 3306 def plot(*args, **kwargs):
-> 3307 ax = gca() 3308 # Deprecated: allow callers to override the hold state 3309 # by passing hold=True|False
C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py in gca(**kwargs)
948 matplotlib.figure.Figure.gca : The figure's gca method.
949 """
--> 950 return gcf().gca(**kwargs)
951
952 # More ways of creating axes:
C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py in gcf()
584 return figManager.canvas.figure
585 else:
--> 586 return figure()
587
588
C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py in figure(num,
figsize, dpi, facecolor, edgecolor, frameon, FigureClass, **kwargs)
533 frameon=frameon,
534 FigureClass=FigureClass,
--> 535 **kwargs)
536
537 if figLabel:
C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4agg.py
in new_figure_manager(num, *args, **kwargs)
44 FigureClass = kwargs.pop('FigureClass', Figure)
45 thisFig = FigureClass(*args, **kwargs)
---> 46 return new_figure_manager_given_figure(num, thisFig)
47
48
C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4agg.py
in new_figure_manager_given_figure(num, figure)
51 Create a new figure manager instance for the given figure.
52 """
---> 53 canvas = FigureCanvasQTAgg(figure)
54 return FigureManagerQT(canvas, num)
55
C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4agg.py
in __init__(self, figure)
74 if DEBUG:
75 print('FigureCanvasQtAgg: ', figure)
---> 76 FigureCanvasQT.__init__(self, figure)
77 FigureCanvasQTAggBase.__init__(self, figure)
78 FigureCanvasAgg.__init__(self, figure)
C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4.py in
__init__(self, figure)
64
65 # Note different super-calling style to backend_qt5
---> 66 QtWidgets.QWidget.__init__(self)
67 FigureCanvasBase.__init__(self, figure)
68 self.figure = figure
TypeError: __init__() missing 1 required positional argument: 'figure'
我正在使用Windows电脑上的Jupyter笔记本。使用%matplotlib inline
一切正常,可以生成内嵌图片,但使用%matplotlib qt
时就不行了。
。我该怎么办?
%matplotlib qt5```也给我报错了。 - just_learning