amaatouq
amaatouq

Reputation: 2337

stacking multiple seaborn.catplot on top of each other

I have multiple different FacetGrid plots using Seaborn (from different dataframes that can't be merged).

Each plot is

g = sns.catplot(x="type", y=outcome, 
                        hue="team",
                        order=types
                        ,ci=68.2,
                        kind="point",aspect=1.3,
                        data=df_temp)

which will give me 6 of these plots (only two are shown as example) enter image description here enter image description here

I want to stack them on top of each other to have one single plot with both HH and MH values on the same ax. To get something like this: enter image description here

I tried having a fig = plt.figure() outside the loop and then fig.axes.append(g.ax) inside the loop (over the 6 dataframes) but it didn't work out (I get an empty array in fig.axes)

Is there a way to do that?

Upvotes: 1

Views: 4064

Answers (1)

Sheldore
Sheldore

Reputation: 39072

Try passing the axis ax. catplot does not accept ax paramater.

EDIT: Based on your own suggestion, pointplot works when passed the axis instance ax.

fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(111)

g = sns.pointplot(x="type", y=outcome, hue="team", order=types, 
                  ci=68.2,data=df_temp, ax=ax)

Upvotes: 3

Related Questions