How to Plot y=x^2 Using Matplotlib?

  • Context: Python 
  • Thread starter Thread starter joseph2015
  • Start date Start date
  • Tags Tags
    Matplotlib Plotting
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 3K views
joseph2015
Messages
14
Reaction score
2
TL;DR
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
[CODE lang="python" title="plotting" highlight="7,8"]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()[/CODE]
 
on Phys.org
Thank you very much for your replies and helps