Reputation: 655
I'm using the latest matplotlib, version 2.0.0, installed via pip on Mac OSX Sierra. The problem is that the following example does not work as expected as no figure is shown. Note that I'm calling show()
on the figure1
object because I want to show only figure1
. If I use plt.show()
it works but it shows both figure1
and figure2
which I don't want.
import matplotlib.pyplot as plt
figure1 = plt.figure()
# I need figure2 for something else but I don't want to show it.
figure2 = plt.figure()
figure1.show()
# The following would work, but I want to show
# only figure1 and not also figure2.
# plt.show()
Upvotes: 1
Views: 5693
Reputation: 339120
figure.show()
makes sense in interactive mode, not for permanently showing a figure. So you need to use plt.show()
. In order not to show the second figure, you may close it beforehands,
plt.close(figure2)
plt.show()
Upvotes: 2