如何针对一个列表绘制列表列表

时间:2018-07-18 10:34:41

标签: python python-3.x matplotlib

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()

输出为:output image I got. But I want both plots to be in one figure

[VI上方包含2个列表,每个列表包含4个元素。我想在同一XY图中绘制VI。 V和I数据将具有2个图。 ]

1 个答案:

答案 0 :(得分:1)

只需压缩V和I,即可获得元组列表,然后绘制每个元组

for t in zip(V,I):
    plt.plot(*t)

plt.show()

结果

Output plot