5

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?

4
  • matplotlib.pyplot.figure() will open a new figure window for you, if that's what you mean. Commented Jan 28, 2017 at 2:14
  • 1
    you can always do your figure bigger by using figsize=(width,height) specifying width and height in inches inside matplotlib.pyplot.figure() and then use subplots. Commented Jan 28, 2017 at 5:15
  • 1
    Possible duplicate of matplotlib: multiple plots on one figure Commented Jan 28, 2017 at 5:46
  • @WKK I don't think it's clear what you mean by "two or more plots on the same drawing paper". Can you edit the question to explain more clearly what you're trying to do? Commented Jan 28, 2017 at 6:20

1 Answer 1

7

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.