gpt4 book ai didi

matplotlib - PyQt4/matplotlib :How to fix MatplotlibDeprecationWarning due to axes. 保持()

转载 作者:行者123 更新时间:2023-12-01 13:16:19 27 4
gpt4 key购买 nike

我在 python3.6 中使用 matplotlib。我的程序运行成功,但它显示以下警告消息:

/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() 现在默认总是设置为 true,所以你可以成功删除这行代码:self.axes.hold(True) 开心点。

Check out the Docs

关于matplotlib - PyQt4/matplotlib :How to fix MatplotlibDeprecationWarning due to axes. 保持(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54684123/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com