eran
eran

Reputation: 15156

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?

Upvotes: 7

Views: 17210

Answers (1)

pelson
pelson

Reputation: 21849

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')

Upvotes: 14

Related Questions