开发者

Delete lines in matplotlib

开发者 https://www.devze.com 2022-12-29 01:09 出处:网络
I need to delete all the lines on a subplot, to then redr开发者_如何学Pythonaw them (i\'m making a redraw function to be used when i add/remove some lines)

I need to delete all the lines on a subplot, to then redr开发者_如何学Pythonaw them (i'm making a redraw function to be used when i add/remove some lines) How do I do it?


If you have the Axes object stored, you reference each line by the lines member:

ax = fig.add_subplot(111)
ax.plot(line one)
ax.plot(line two)
# plot
ax.lines.pop(0) # removes the first line
# plot again


ax.lines is just a Python list

ax = plt.gca()
ax.lines.clear()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号