How to set some xlim and ylim in Seaborn lmplot facetgrid

I'm using Seaborn's lmplot to plot a linear regression, dividing my dataset into two groups with a categorical variable.

For both x and y, I'd like to manually set the lower bound on both plots, but leave the upper bound at the Seaborn default. Here's a simple example:

    import pandas as pd
    import seaborn as sns
    import random

    n = 200
    base_x = [random.random() for i in range(n)]
    base_y = [2*i for i in base_x]
    errors = [random.uniform(0,1) for i in range(n)]
    y = [i+j for i,j in zip(base_y,errors)]

    df = pd.DataFrame({'X': base_x,
                       'Y': y,
                       'Z': ['A','B']*(n/2)})

    mask_for_b = df.Z == 'B'
    df.loc[mask_for_b,['X','Y']] = df.loc[mask_for_b,] *2


This outputs the following: enter image description here

But in this example, I'd like the xlim and the ylim to be (0,*) . I tried using sns.plt.ylim and sns.plt.xlim but those only affect the right-hand plot. Example:


enter image description here

How can I access the xlim and ylim for each plot in the FacetGrid?

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



enter image description here