【发布时间】:2015-09-19 03:37:36
【问题描述】:
我正在尝试将 x 轴限制设置为 Seaborn facetgrid distplot 的每个方面的不同值。我知道我可以通过 g.axes 访问子图中的所有轴,因此我尝试遍历它们并将 xlim 设置为:
g = sns.FacetGrid(
mapping,
col=options.facetCol,
row=options.facetRow,
col_order=sorted(cols),
hue=options.group,
)
g = g.map(sns.distplot, options.axis)
for i, ax in enumerate(g.axes.flat): # set every-other axis for testing purposes
if i % 2 == 0[enter link description here][1]:
ax.set_xlim(-400, 500)
else:
ax.set_xlim(-200, 200)
但是,当我这样做时,所有轴都设置为 (-200, 200) 而不仅仅是其他方面。
我做错了什么?
【问题讨论】:
-
如果您希望轴有不同的限制,您需要将
False传递给sharey和sharex。 -
这条评论应该是被接受的答案^^