【发布时间】:2018-07-18 10:34:40
【问题描述】:
import matplotlib.pyplot as plt
V = [[10,20,30,40],[30,40,50,50,70]] # It may consist n lists, each list with m values
I = [[1,2,3,4],[3,4,5,6,7]] # It may consist n lists, each list with m values
for t in list(zip(V,I)):
plt.plot(*t)
plt.show()
[以上V和I由2个列表组成,每个列表有4个元素。我想在同一个 XY 图中绘制 V 和 I。这个 V 和 I 数据将有 2 个图。 ]
【问题讨论】:
-
显示你尝试过的代码。
-
我投票结束这个问题,因为他只是要求我们为他编写代码
-
迭代
V和I列表中的zip会产生 n 个x和y对,您可以使用它们来绘制该特定对。 -
我只是 Python(3 天)和 stackoverflow(4 小时)的初学者。不知道怎么写,求大神帮忙。对不起。我并不是说有人会为我编写代码。我尝试了我的方法。但是,无法得到它。我已经为上面的代码添加了错误输出。
-
你需要展示你用来尝试解决这个问题的代码。如错误消息所示,您不能仅使用
plt.plot(V,I)绘制嵌套列表。无论如何,@taras 在他们的评论中给了你方法
标签: python python-3.x matplotlib