matplotlib - PyQt4/matplotlib:如何修复 MatplotlibDeprecationWarning 由于 axes.hold()
问题描述
我正在将 matplotlib 与 python3.6 一起使用。我的程序运行成功,但显示以下警告消息:
/home/sree/python/PyPrgm.py:41:MatplotlibDeprecationWarning:axes.hold 已弃用。
我引用了 http://matplotlib.org/api/api_changes.html。我怎样才能摆脱这个警告?
class PyTabWidget(QTabWidget):
def __init__(self):
super(PyTabWidget,self).__init__()
tab1=FirstTab()
self.addTab(tab1,"TAB1")
class FirstTab(QTabWidget):
def __init__(self):
super(FirstTab,self).__init__()
grp1=QGroupBox("GroupBox1")
grp1.setStyleSheet("QGroupBox { border:1px ; background-color:white}")
graph=TwoD_GraphWindow() #2D graphWindow object
layout=QGridLayout() #create layout
layout.setColumnMinimumWidth(0, 10)
layout.setColumnMinimumWidth(2, 10)
layout.setColumnMinimumWidth(4, 10)
layout.setRowMinimumHeight(0, 10)
layout.setRowMinimumHeight(4, 10)
layout.addWidget(graph, 2, 2)
self.setLayout(layout) #set the layout
A=np.linspace(0,10,100)
graph.DrawGraph(A) #invoke DrawGraph() function
class TwoD_GraphWindow(FigureCanvas): #Class for 2D window
def __init__(self):
self.fig=Figure() #Figure() object
self.axes = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig) #creating FigureCanvas
self.setWindowTitle("Main") # sets Window title
def DrawGraph(self, x):#Fun for Graph plotting
self.axes.clear() #clear the axes
self.axes.plot(x,np.sin(x),'-' ) #plots the 2D graph
self.axes.hold(True) #do not clear the axis
self.axes.plot(x,np.cos(x),'--');
self.draw()
解决方案
文档说Axes.hold()
now 始终true
默认设置为,因此您可以成功删除这行代码:
self.axes.hold(True)
并且很高兴。
推荐阅读
- sql-server - 重新安装 SYBASE oledb 提供程序后,它不会出现在 SSIS 连接管理器中
- r - R - 在循环中调用带有可变参数的函数
- c# - 在运行时向红隼添加/删除应用程序部分
- meshlab - 导出后失去质感?
- javascript - 过滤数组对象 JavaScript
- three.js - 禁用某些分组 object3D 的边界框计算
- javascript - javascript 新手,如何更改 --> document.write(schedule[row]['title']) 的颜色;变红?
- sql - 内置分析功能不应用于前 N 行的功能
- c# - IQueryable 条件包含
- c# - Vector3.MoveTowards() 不适用于 TouchInputs