【发布时间】:2012-03-08 01:22:45
【问题描述】:
所以我初始化了一个pyplot图
import ... ## import all relevent modules
f = plt.figure(figsize=(8,3),dpi(100)
a = plt.subplot(111)
a.set_xlim(left=0,right=25,auto=False)
a.set_ylim(bottom=0,top=250,auto=False)
a.plot([5,10,15],[80,150,210])
plt.show()
这很好用...我想做的是编写一个可以动态更新散点图的函数...类似于:
def plot_point(x_coord,y_coord):
a.plot([x_coord],[y_coord])
a.draw() ## I thought this would work... :(
没有错误,但没有绘制点。我怎样才能解决这个问题?我使用图形完成它的原因是我可以将它嵌入到 Tkinter 中。
感谢您的帮助!
【问题讨论】:
-
您说的是“散点图”,但您使用的是 .plot(),而不是 .scatter();您想要更新的线还是散点图上的新点?
-
散点图上的新点。让我尝试使用 scatter() 而不是 plot()
-
有效!谢谢帝斯曼!这么小的问题。 :)
标签: python tkinter matplotlib