1

How to update figure text in matplotlib figure in python 2.7?

t = figtext(.78,.92, "Combined- Sensors ", horizontalalignment = 'center',fontsize=15,color= 'm')

I have tried using t.remove() but I am getting an error:

traceback (most recent call last):
  File "C:\Python27\combined.py", line 245, in <module>
    t.remove()
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 137, in remove
    raise NotImplementedError('cannot remove artist')
NotImplementedError: cannot remove artist

Is there any other way to do this?

1 Answer 1

3

You can remove a the figtext using the code below, assuming your figtext object has been saved to a variable t.

plt.gcf().texts.remove(t)
plt.draw()

plt.gcf() will get the current figure object. If you already have the figure object, say for example you created it with fig = plt.figure() before doing your plotting, then you can just use fig.texts.remove(t).

You need to call plt.draw() after you have removed the object to re-draw the plot and hence show the removal.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.