简体   繁体   English

如何使用matplotlib的Pyplot模块绘制两个数据数组

[英]how to use Pyplot module of matplotlib to plot two arrays of data

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" 我写了这段代码:我写了这段代码:我试图绘制两个数组x“数据编号”和y“数据本身”

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 问题出在哪儿

After plotting the data with plt.plot(x,y) you need to show the plot with plt.show() . 使用plt.plot(x,y)绘制数据后plt.plot(x,y)您需要使用plt.show()显示该图。 Alternatively you can save the plot directly to disk with plt.savefig("Myfile.png",format="png") . 或者,您可以使用plt.savefig("Myfile.png",format="png")将图直接保存到磁盘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM