Plotting y=x^2 with Matplotlib

  • #1
14
2
TL;DR Summary
Hello all
I would like to plot my outcome with lines. So line 7 workes but it produces markers such as (o or ^). My question is how to make line 8 works to plot lines instead of discrete points?
Thanks in advance

Joe
plotting:
import matplotlib.pyplot as plt

R = 2

for x in range(0,50):
     y = x**R
#    plt.plot(x,y,marker = 'o')
     plt.plot(x,y,'--')

plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('plot test')
plt.legend()
plt.show()
 
  • #5
I think you want
Code:
plt.plot(x,y,'-')
 
  • #7
Thank you very much for your replies and helps
 

Suggested for: Plotting y=x^2 with Matplotlib

Replies
1
Views
8K
Replies
8
Views
684
Replies
3
Views
2K
Replies
9
Views
1K
Replies
4
Views
5K
Replies
6
Views
6K
Replies
3
Views
1K
Replies
1
Views
1K
Replies
3
Views
688
Back
Top