Pandas绘制了4个数据帧系列的2个子图

时间:2018-04-08 15:24:31

标签: python pandas matplotlib

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

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

1 个答案:

答案 0 :(得分:1)

如果我正确理解您之前提出的问题,那么您正在寻找类似的内容:

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