首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复由于axes.hold()而导致的MatplotlibDeprecationWarning

如何修复由于axes.hold()而导致的MatplotlibDeprecationWarning
EN

Stack Overflow用户
提问于 2019-02-14 14:03:31
回答 1查看 203关注 0票数 3

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

/home/sree/python/PyPrgm.py:41:MatplotlibDeprecationWarning:axes.hold已弃用。

我引用了http://matplotlib.org/api/api_changes.html。我怎样才能摆脱这个警告?

代码语言:javascript
运行
复制
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()
EN

回答 1

Stack Overflow用户

发布于 2019-02-14 14:15:26

文档显示,默认情况下,Axes.hold() now总是设置为true,因此您可以成功地删除以下代码行:self.axes.hold(True),并感到高兴。

Check out the Docs

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54684123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档