'hold off' equivalent in python

  • #1
435
29
In MATLAB one can 'hold off' to remove a previously drawn thing on the same graph. How about in python?
 
Last edited:

Answers and Replies

  • #3
Your intent is to draw multiple traces on the same plot?

It would depend on the choice of plotting software accessed by python. A common one is matplotlib where it is possible. These examples may help:

https://www.programcreek.com/python/example/56588/matplotlib.pyplot.hold
Thanks very much. I want to draw 2 things in the same graph and show them 1 at a time (1st appears, 1st vanishes, 2nd appears...). I used plt.hold('off') but it was reported as an error.
 
  • #4
When you are using a library like matplotlib you should refer to the API documentation provided by the developers. Using an IDE also helps as it will describe the arguments used by API methods.
 
  • Like
Likes sysprog and jedishrfu
  • #5
When you are using a library like matplotlib you should refer to the API documentation provided by the developers. Using an IDE also helps as it will describe the arguments used by API methods.
Seems that hold(), obsolete, is no longer recognized.
 
  • #6
Python:
from matplotlib import pyplot as plt
# Note the , in the next line: pyplot.plot returns a list and we
# want the first element which is a collection of 2DLines.
currentPlot, = plt.plot([1, 4, 9, 16])
# This will remove the collection of lines from the plot.
currentPlot.remove()
 
  • Like
  • Informative
Likes Wrichik Basu and sysprog

Suggested for: 'hold off' equivalent in python

Replies
1
Views
462
Replies
2
Views
286
Replies
10
Views
1K
Replies
24
Views
916
Replies
9
Views
969
Replies
5
Views
965
Replies
1
Views
408
Replies
15
Views
842
Replies
2
Views
628
Back
Top