📜  matplotlib 删除绘制的文本 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:03.134000             🧑  作者: Mango

代码示例1
# instead of drawing your text like this
fig.text(0, 0, 'My text')

# you can do
textvar = fig.text(0, 0, 'My text')

# If you've lost the references, though, all the text objects
# can be found in the texts attribute:
fig.texts # is a list of Text objects

# In version 1.3.1, doing textvar.remove() generates a NotImplementedError
# (apparently fixed in 1.4). However, you can get around that to some
# degree by setting the visibility to False.

for txt in fig.texts:
    txt.set_visible(False)