I have the following Seaborn FaceGrid output:
generated with a snippet like this:
imax = 3
df = pd.DataFrame(columns = ['x','y','i'])
for i in range(imax):
# Creating vectors X and Y
x = np.linspace(0, 1/(2 ** i),101)
y = x ** x
df = df.append(pd.DataFrame({'x': x, 'y': y, 'i':i}), ignore_index = True)
g = sns.FacetGrid(df, col='i')
g = g.map(sns.lineplot, 'x', 'y')
import matplotlib.pyplot as plt
plt.show()
(See this gist for the full source.)
In the grid I would like the x axes always be adjusted to the available x values for the respective "i". How can I do this?
What I have tried
I called set_xbound
on the axes
objects:
for i,b in enumerate(g.axes[0]):
b.set_xbound(0, 1/(2 ** i))
but this sets the x-scale to [0,0.25]
for all subplots, while I obviously want for the first subplot [0,1]
, then [0.5]
and only for the last subplot [0,0.25]
.