Seaborn: lmplot(sharey=False) not working

Created on 17 Mar 2021  路  3Comments  路  Source: mwaskom/seaborn

The following code behaves as if sharey=True.
(edit: actually, it does not behave the same, but it is still not rescaling the plots individually the way it should)

df=pd.DataFrame({'x':[1,2,3,1,2,3], 'y':[4,5,2,400,500,200], 't':[1,1,1,2,2,2]}) 
sns.lmplot(data=df, x='x', y='y', col='t', sharey=False);

If you do this, it suddenly works:

sns.lmplot(data=df, x='x', y='y', col='t', sharex=False, sharey=False);

Versions of seaborn and matplotlib:

sns.__version__ 
'0.11.1'

matplotlib.__version__
'3.3.1'

image

bug regression

All 3 comments

Worth noting: the y axes are not shared in the "wrong" plot, however the y axis autoscaling is off.

My suspicion is that this line is the culprit: https://github.com/mwaskom/seaborn/blob/master/seaborn/regression.py#L611-L616

"the y axes are not shared in the "wrong" plot"

You are right, the scales aren't actually identical. I didn't notice that.

It's fortunate as it makes the workaround (setting the ylim explicitly) a lot easier to accomplish than "unsharing" the axes, which is pretty difficult in matplotlib IIRC.

Was this page helpful?
0 / 5 - 0 ratings