首页 > 解决方案 > 如何在 seabron 中使用 facet-grid 更改网格大小

问题描述

我正在绘制分面网格,以便我的 x 轴刻度是日期(dd-mm-yy),它看起来不太好。有没有办法改变网格的大小(比如 figsize)?

g = sns.FacetGrid(c53_grid, col='question',col_wrap = 4, 
margin_titles=True)
g = g.map(plt.plot, "submitted_at", "int_value_0")
g = g.map(plot_mean, 'int_value_0', ls=":", c=".5")
g.set_titles("{col_name}")
g.set_xticklabels(rotation = 45)

标签: pythonseabornfacet-grid

解决方案


您可以设置height参数(以英寸为单位的值)和aspect参数 ( height*aspect=width)。

在你的情况下:

g = sns.FacetGrid(c53_grid, col='question',col_wrap = 4, 
margin_titles=True, height=3, aspect= 1,33) #4/3 ratio
g = g.map(plt.plot, "submitted_at", "int_value_0")
g = g.map(plot_mean, 'int_value_0', ls=":", c=".5")
g.set_titles("{col_name}")
g.set_xticklabels(rotation = 45)

我建议你看看文档


推荐阅读