Matplotlib graph with typical linestyle not showing
up vote
0
down vote
favorite
I want a very simple plot:
import matplotlib.pyplot as plt
import numpy as np
for t in np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-', linewidth=7)
plt.show()
But nothing is appearing. I just get an empty plot. Where is my error?
python matplotlib
add a comment |
up vote
0
down vote
favorite
I want a very simple plot:
import matplotlib.pyplot as plt
import numpy as np
for t in np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-', linewidth=7)
plt.show()
But nothing is appearing. I just get an empty plot. Where is my error?
python matplotlib
1
Matplotlib can plot arrays. There's no need to loop here
– DavidG
Nov 8 at 17:06
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want a very simple plot:
import matplotlib.pyplot as plt
import numpy as np
for t in np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-', linewidth=7)
plt.show()
But nothing is appearing. I just get an empty plot. Where is my error?
python matplotlib
I want a very simple plot:
import matplotlib.pyplot as plt
import numpy as np
for t in np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-', linewidth=7)
plt.show()
But nothing is appearing. I just get an empty plot. Where is my error?
python matplotlib
python matplotlib
edited Nov 8 at 17:06
DavidG
10.1k102939
10.1k102939
asked Nov 8 at 16:55
waynemystir
4317
4317
1
Matplotlib can plot arrays. There's no need to loop here
– DavidG
Nov 8 at 17:06
add a comment |
1
Matplotlib can plot arrays. There's no need to loop here
– DavidG
Nov 8 at 17:06
1
1
Matplotlib can plot arrays. There's no need to loop here
– DavidG
Nov 8 at 17:06
Matplotlib can plot arrays. There's no need to loop here
– DavidG
Nov 8 at 17:06
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Just plot the whole arrays:
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-',linewidth=7)
plt.show()
add a comment |
up vote
0
down vote
Each call to plt.plot within the for loop is plotting a separate 'line' that consists on only a single point.
if you want the code to work you should plot points instead of lines.
for t in np.linspace(0,2*np.pi,100): plt.plot(np.cos(t), np.sin(t), 'k.')
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Just plot the whole arrays:
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-',linewidth=7)
plt.show()
add a comment |
up vote
0
down vote
accepted
Just plot the whole arrays:
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-',linewidth=7)
plt.show()
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Just plot the whole arrays:
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-',linewidth=7)
plt.show()
Just plot the whole arrays:
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,2*np.pi,100):
plt.plot(np.cos(t), np.sin(t), color='blue', linestyle='-',linewidth=7)
plt.show()
answered Nov 8 at 17:14
user8408080
77238
77238
add a comment |
add a comment |
up vote
0
down vote
Each call to plt.plot within the for loop is plotting a separate 'line' that consists on only a single point.
if you want the code to work you should plot points instead of lines.
for t in np.linspace(0,2*np.pi,100): plt.plot(np.cos(t), np.sin(t), 'k.')
add a comment |
up vote
0
down vote
Each call to plt.plot within the for loop is plotting a separate 'line' that consists on only a single point.
if you want the code to work you should plot points instead of lines.
for t in np.linspace(0,2*np.pi,100): plt.plot(np.cos(t), np.sin(t), 'k.')
add a comment |
up vote
0
down vote
up vote
0
down vote
Each call to plt.plot within the for loop is plotting a separate 'line' that consists on only a single point.
if you want the code to work you should plot points instead of lines.
for t in np.linspace(0,2*np.pi,100): plt.plot(np.cos(t), np.sin(t), 'k.')
Each call to plt.plot within the for loop is plotting a separate 'line' that consists on only a single point.
if you want the code to work you should plot points instead of lines.
for t in np.linspace(0,2*np.pi,100): plt.plot(np.cos(t), np.sin(t), 'k.')
answered Nov 8 at 17:00
BioHazZzZard
1
1
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212564%2fmatplotlib-graph-with-typical-linestyle-not-showing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Matplotlib can plot arrays. There's no need to loop here
– DavidG
Nov 8 at 17:06