How to set some xlim and ylim in Seaborn lmplot facetgrid How to set some xlim and ylim in Seaborn lmplot facetgrid python python

How to set some xlim and ylim in Seaborn lmplot facetgrid


The lmplot function returns a FacetGrid instance. This object has a method called set, to which you can pass key=value pairs and they will be set on each Axes object in the grid.

Secondly, you can set only one side of an Axes limit in matplotlib by passing None for the value you want to remain as the default.

Putting these together, we have:

g = sns.lmplot('X', 'Y', df, col='Z', sharex=False, sharey=False)g.set(ylim=(0, None))

enter image description here

Update

  • Positional arguments, sharex and sharey are deprecate beginning in seaborn 0.11
g = sns.lmplot(x='X', y='Y', data=df, col='Z', facet_kws={'sharey': False, 'sharex': False})g.set(ylim=(0, None))


You need to get hold of the axes themselves. Probably the cleanest way is to change your last row:

lm = sns.lmplot('X','Y',df,col='Z',sharex=False,sharey=False)

Then you can get hold of the axes objects (an array of axes):

axes = lm.axes

After that you can tweak the axes properties

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

creates:

enter image description here