Matplotlib-如何删除特定的线或曲线 [英] Matplotlib - How to remove a specific line or curve
本文介绍了Matplotlib-如何删除特定的线或曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除多条线图中的特定线.贝娄是一个给定的示例,对我来说还不够,因为它仅删除最后绘制的线条,而不删除我要删除的线条.我怎样才能做到这一点?如何在整个程序中寻址特定行(按名称,编号,参考)并删除该行?
I want to remove a specific line in a plot of multiple lines. Bellow is a given example which is not sufficient for me because it removes only the last plotted line and not the line that I want to remove. How can I do that? How can I address a specific line(by name, by number, by reference) throughout the program and delete that line?
self.axes.lines.remove(self.axes.lines[0])
推荐答案
几乎所有绘图功能都返回对在以下示例中创建的artist
对象的引用:
Almost all of the plotting functions return a reference to the artist
object created ex:
ln, = plot(x, y) # plot actually returns a list of artists, hence the ,
im = imshow(Z)
如果您有参考文献,则可以通过remove
(doc)函数,例如:
If you have the reference you can remove an artist via the remove
(doc) function ex:
ln.remove()
im.remove()
这篇关于Matplotlib-如何删除特定的线或曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文