【发布时间】:2021-12-28 14:57:13
【问题描述】:
我正在尝试创建一个包含大量子图的熊猫图,在本例中为 58 个。数据是宽格式,格式类似于:
df =
Date It1 It2 It3... Itn
0 x x x n
1 x x x n
2 x x x n
3 x x x n
我已经能够用 pandas 情节创建情节了:
rows = df.shape[1]//2
df.plot(legend = True, subplots = True, layout = (rows,5), grid=True, title="Labs", sharex=True, sharey=False,figsize=(12,32),)
plt.show()
但我无法设置图例的位置,因此所有图表都清晰易读,这是当前外观的示例:
我已经在另一个堆栈溢出帖子中尝试了这两种解决方案 - Set the legend location of a pandas plot
...但实际上都没有工作。我也尝试按照这个答案使用tight_layout(),但它同样难以辨认-Plot pandas dataframe with subplots (subplots=True): Place legend and use tight layout
任何人都可以提供有关如何放置具有如此多图表的图表的图例并仍然保持可读性的任何指导吗?
【问题讨论】:
标签: python pandas matplotlib plot legend