1

When I run this code, I do have one plot printing my two data sets a and b. I would like them to be displayed on two separate plots. Thanks in advance

import matplotlib.pyplot as plt

a = range(0,10)
b= range(2,12)

plt.plot(a)
plt.plot(b)
1
  • You're asking a design question. SO is really about helping you fix code that doesn't work. Please, attempt a solution and post it here so we can discuss how your solution can be improved. Commented Jan 1, 2015 at 19:41

2 Answers 2

1

The tutorial shows how to do this. You need to utilize the show() method after each plot.

plt.plot(a)
plt.show()
plt.plot(b)
plt.show()

Alternatively, you can show both at the same time utilizing subplots:

plt.subplot(2, 1, 1)
plt.plot(a)

plt.subplot(2, 1, 2)
plt.plot(b)

plt.show()

This creates the following plot:

Subplots

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

Comments

1

You can use the show() method :

import matplotlib.pyplot as plt

a = range(0,10)
b= range(2,12)

plt.plot(a)
plt.show()

plt.plot(b)
plt.show()

1 Comment

Merci Paul :) ca aide beaucoup

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.