Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flushing all current figures in matplotlib

Say I did

figure(1)
plot(...)
figure(2)
plot(...)

and I want to create a third figure and show only that one. so that:

figure(1)
plot(...)
figure(2)
plot(...)
somemagicFuncToFlushFigures()
figure(3)
plot(...)
show()

will only show the third figure. How do I do that?

like image 807
eran Avatar asked Nov 01 '12 09:11

eran


People also ask

How do I refresh a plot in Matplotlib?

To update the plot with x and y values, we use ion() function. To plot the line, we use plot() function. To define labels, we use xlabel() and ylabel() function. Then we update the variables x and y with set_xdate() and set_ydata() function.


1 Answers

You want to close the figures right? I wonder if the following helps?

import matplotlib.pyplot as plt
plt.close()

UPDATE: As @jorgeca says, to close all the figures try using plt.close('all')

like image 183
pelson Avatar answered Oct 16 '22 08:10

pelson