设置seaborn lmplot列的单个ylim [英] set individual ylim of seaborn lmplot columns

查看:180
本文介绍了设置seaborn lmplot列的单个ylim的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令制作了lmplot列图(子图):

I've made a lmplot column plot (subplot) using the following commands:

g = sns.lmplot(x=COX, y='dX', data=tidy_data, hue='hue', col='comp', 
col_wrap=8, fit_reg=True, scatter=True, aspect=1.5,
            legend_out=True, truncate=True, scatter_kws={"s": 200})

绘制的lmplot FacetGrid的图形

FacetGrid似乎将所有子图的ylim设置为所有数据中的最大值.我想为每个子图分别设置ylim.我首先看了这个问题的答案:

The FacetGrid seems to set the ylim of all subplots to the maximum value in all of the data. I would like to set the ylim individually for each subplot. I first looked to the answer of this question:

如何设置一些xlim和ylim在Seaborn lmplot facetgrid中

我测试过:

g.axes.shape
>>> (23, )

g.axes[0]
>>> AxesSubplot(0.0189366,0.704381;0.116079x0.258196)

g.axes[0].set_ylim(0, 1)
>>> 

但是,对于所有子图,此方法似乎也给出相同的ylim.也许我没有访问右轴?我真的很感谢您的帮助.

However, this method also seems to give the same ylim for all subplots. Maybe I'm not accessing the right axis? I'd really appreciate some help.

推荐答案

如果您希望能够更改FacetGrid中某个特定图的ylim,则必须使用g = sns.lmplot(..., sharey=False)

If you want to be able to alter the ylim of one particular plot in the FacetGrid you have to explicitly create it with g = sns.lmplot(..., sharey=False)

示例:

tips = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", col="day", hue="day", data=tips, col_wrap=2, size=3, 
               sharey=False)
g.axes[0].set_ylim((0,100))

这篇关于设置seaborn lmplot列的单个ylim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆