Reputation: 41
so this a section of my code, it runs and opens a graph but there is no plot points
fig =plt.figure(1)
data= [1.3,2.4]
for i in range(0,2):
emittx=data[i];
turns = 1+i;
plt.plot(turns,emittx,'-r')
plt.show()
stuck because I cant really understand why
Upvotes: 2
Views: 2315
Reputation: 1385
As was stated in the comments, the problem is because you are repeatedly (for loop) plotting a SINGLE point and asking matplotlib to use a line ('-') to connect the single point.
Either plot an array of two or more points (e.g. [2.3, 4.4]) or use markers to represent the data ('o'). For example:
fig =plt.figure(1)
data = [1.3,2.4]
for i in range(0,2):
emittx=data[i];
turns = 1+i;
plt.plot(turns,emittx,'or', markersize=10)
plt.show()
should allow you to plot single points.
Upvotes: 2