gpt4 book ai didi

python - Pandas 绘制 4 个数据帧系列中的 2 个子图

转载 作者:行者123 更新时间:2023-12-01 09:33:46 26 4
gpt4 key购买 nike

我可以在一张图中绘制数据帧每个系列的许多子图,如下所示:

import pandas as pd

NG = [1,2,3,4,5,6,7]
dflist = []

l = [1,2,3,4,5,6]
b = [6,5,4,3,2,1]


for n in NG:
df = pd.DataFrame(l)
dflist.append(df)
df2 = pd.DataFrame(b)
dflist.append(df2)
df = pd.concat(dflist, axis = 1)

df.plot(grid = 1, subplots = True, layout = (7,2), sharey = True)

print(df)

enter image description here

如何合并每隔一个图?它应该看起来像这样:

enter image description here

最佳答案

如果我正确理解你之前的问题和这个,你正在寻找这样的东西:

import pandas as pd

l = [1,2,3,4,5,6]
b = [6,5,4,3,2,1]

for n in range(7):
dflist = []
df = pd.DataFrame(l)
dflist.append(df)
df2 = pd.DataFrame(b)
dflist.append(df2)
df = pd.concat(dflist, axis = 1)
ax = subplot(4, 2, n + 1)
df.plot(ax=ax);

enter image description here

关于python - Pandas 绘制 4 个数据帧系列中的 2 个子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49719479/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com