Plotting list of lists in a same graph in Python

杀马特。学长 韩版系。学妹 提交于 2019-12-06 02:30:07

问题


I am trying to plot (x,y) where as y = [[1,2,3],[4,5,6],[7,8,9]].

Say, len(x) = len(y[1]) = len(y[2]).. The length of the y is decided by the User input. I want to plot multiple plots of y in the same graph i.e, (x, y[1],y[2],y[3],...). When I tried using loop it says dimension error.

I also tried: plt.plot(x,y[i] for i in range(1,len(y)))

How do I plot ? Please help.

for i in range(1,len(y)):
plt.plot(x,y[i],label = 'id %s'%i)
plt.legend()
plt.show()

来源:https://stackoverflow.com/questions/40073322/plotting-list-of-lists-in-a-same-graph-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!