[英]Updating a graph/plot by looping over a list using matplotlib or seaborn
I have a list of 5000 elements.我有一个包含 5000 个元素的列表。 Each element of this list has 2 separate lists (let's say x and y) in it with 128 variables each.
这个列表的每个元素都有 2 个单独的列表(假设 x 和 y),每个列表有 128 个变量。 Now I want to plot 5000 lines of x and y in the same graph.
现在我想在同一个图中绘制 5000 条 x 和 y 线。 The list is of the following form:
该列表采用以下形式:
my_list = [
[[1_a1,1_a2,1_a3...,1_a128],[1_b1,1_b2,1_b3...,1_b128]],
[[2_a1,2_a2,2_a3...,2_a128],[2_b1,2_b2,2_b3...,2_b128]],
......,
[[5000_a1,5000_a2,5000_a3...,5000_a128],[5000_b1,5000_b2,5000_b3...,5000_b128]]
]
I have tried using matplotlib but I am getting 5000 separate plots, however, I need 5000 lines in one plot我曾尝试使用 matplotlib,但我得到了 5000 个单独的图,但是,我需要在一个图中使用 5000 行
for i in range(0,len(empty),1): #empty is my_list
fig1 = plt.figure()
plt.plot(empty[i][0],empty[i][1], 'r', linewidth=1)
plt.grid(True)
plt.xlabel('Heat flow in kW')
plt.ylabel('Temperature in C')
plt.show()
Since you haven't posted code I'll be guessing
a bit here, but
consider using the following to plot those 5000 lines on one graph:
由于您还没有发布代码,我会在这里猜测
一下,但请
考虑使用以下内容在一张图上绘制这 5000 条线:
import matplotlib.pyplot as plt
import numpy as np
# my_list: contains data described above
for sub_list in my_list:
x = np.array(sub_list[0])
y = np.array(sub_list[1])
plt.plot(x, y)
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.