how to use Pyplot module of matplotlib to plot two arrays of data

23.6k views Asked by At

I wrote this code: I wrote this code: I am trying to plot the two arrays x "the data number" and y "the data itself"

for t in range(1, 281):
    data[t] = (3600 + (240 + t * 4) + 281)

for r in range(1, 281):
    sn[r] = r
x = np.array(sn[r])
y = np.array(data[t])
plt.plot(x, y)

where is the problem

1

There are 1 answers

1
Nick On

After plotting the data with plt.plot(x,y) you need to show the plot with plt.show(). Alternatively you can save the plot directly to disk with plt.savefig("Myfile.png",format="png").