Reputation: 179
I would like to plot two or more graphs at once using python
and matplotlib
. I do not want to use subplot since it is actually two or more plots on the same drawing paper.
Is there any way to do it?
Upvotes: 4
Views: 12260
Reputation: 339660
You can use multiple figures and plot some data in each of them. The easiest way of doing so is to call plt.figure()
and use the pyplot statemachine.
import matplotlib.pyplot as plt
plt.figure() # creates a figure
plt.plot([1,2,3])
plt.figure() # creates a new figure
plt.plot([3,2,1])
plt.show() # opens a window for each of the figures
If for whatever reason after creating a second figure you want to plot to the first one, you need to 'activate' it via
plt.figure(1)
plt.plot([2,3,1]) # this is plotted to the first figure.
(Figure numbers start at 1)
Upvotes: 6