我可以在11个图表和1个图中绘制11系列:
NG = [1,2,3,4,5,6,7,8,9,10,11]
serieslist = []
for n in NG:
l = [1,2,3,4,5,6]
df = pd.DataFrame(l)
serieslist.append(df)
df = pd.concat(serieslist, axis = 1)
df.plot(grid = 1, subplots = True, layout = (6,2), sharey = True)
如何在1个图中绘制22个系列(其中2个始终在一个图中)?因此,这意味着在11个图形中有22个图。下面的代码仅给出22个图形:
NG = [1,2,3,4,5,6,7,8,9,10,11]
serieslist = []
for n in NG:
l = [1,2,3,4,5,6]
df = pd.DataFrame(l)
serieslist.append(df)
serieslist.append(df)
df = pd.concat(serieslist, axis = 1)
df.plot(grid = 1, subplots = True, layout = (12,2), sharey = True)
编辑:
这不是我想要的解决方案的100%,但看起来更漂亮:
import pandas as pd
NG = [1,2,3,4,5,6,7,8,9,10,11]
dflist1 = []
dflist2 = []
l = [1,2,3,4,5,6]
b = [6,5,4,3,2,1]
for n in NG:
df = pd.DataFrame(l)
dflist1.append(df)
df = pd.concat(dflist1, axis = 1)
df2 = pd.DataFrame(b)
dflist2.append(df2)
df2 = pd.concat(dflist2, axis = 1)
df.plot(grid = 1, subplots = True, layout = (12,1), sharey = True)
df2.plot(grid = 1, subplots = True, layout = (12,1), sharey = True)
输出:2个图。现在如何将地块组合成1个数字?
最佳答案
您可以使用此matplotlib.pyplot.subplot
。
import matplotlib.pyplot as plt
在单个单元格中:
遍历值
i in range(11)
在迭代我
致电
plt.subplot(6, 2, i + 1)
绘制由输入
i
和i +
组成的DataFrame关于python - Pandas 在1个图中的11个图中绘制了22个系列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49687811/