【问题标题】:Update image in PyPlot在 PyPlot 中更新图像
【发布时间】:2013-02-20 00:31:49
【问题描述】:

下面是我的代码,我要做的就是更新图表上的点。我不想绘制两条线,我只想要一条线。请帮忙

import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [1,4,9,16]

plt.ion()
plt.plot(x,y)
var = raw_input("type enter to change")
#update data some where here?
plt.plot(y,x)
plt.draw()
var = raw_input("type enter to end")

【问题讨论】:

    标签: python graph matplotlib


    【解决方案1】:

    你需要对plot的返回值进行处理,稍后再使用set_data

    import matplotlib.pyplot as plt
    x = [1,2,3,4]
    y = [1,4,9,16]
    
    plt.ion()
    h = plt.plot(x,y)
    plt.show()
    var = raw_input("type enter to change")
    #update data some where here?
    h[0].set_data(y,x)
    plt.show()
    var = raw_input("type enter to end")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-21
      • 2020-11-25
      • 1970-01-01
      • 2018-07-28
      • 1970-01-01
      相关资源
      最近更新 更多