I am using the following code
import seaborn as sns
g = sns.FacetGrid(dataframe, col='A', hue='A')
g.map(plt.plot, 'X', 'Y1')
plt.show()
to make a seaborn facet plot like this:
Now I would like to add another row to this plot with a different variable, call it Y2, on the y axis. The result should look similar to vertically stacking the two plots obtained by
g = sns.FacetGrid(dataframe, col='A', hue='A')
g.map(plt.plot, 'X', 'Y1')
plt.show()
g = sns.FacetGrid(dataframe, col='A', hue='A')
g.map(plt.plot, 'X', 'Y2')
plt.show()
but in a single plot, without the duplicate x axis and titles ("A=<value>") and without creating a new FacetGrid
object.
Note that
g = sns.FacetGrid(dataframe, col='A', hue='A')
g.map(plt.plot, 'X', 'Y1')
g.map(plt.plot, 'X', 'Y2')
plt.show()
does not achive this, because it results in both the curve for Y1 and Y2 being displayed in the same subplot for each value of A.
I used the following code to create a synthetic dataset which appears to match yours:
Then you can do what you want (thanks to @mwaskom in the comments for
)sharey='row', margin_titles=True
):This results in