Ginam Kim
Ginam Kim

Reputation: 25

Combine two graphs of two dataframe into one graph

I want to combine two graphs into one graph. I think it is quite simple but I could not figure it out. haha..

sns.countplot(x=low_tenure.Partner)

enter image description here

sns.countplot(x=high_tenure.Partner)

enter image description here

so I could compare two graphs

Thank you for helping me :)

Upvotes: 0

Views: 593

Answers (2)

Kezif Garbian
Kezif Garbian

Reputation: 338

You could use common axis.

fig = plt.figure()
ax = fig.add_subplot(111)

sns.countplot(data1, ax=ax)
sns.countplot(data2, ax=ax)

Upvotes: 2

Sin-seok Seo
Sin-seok Seo

Reputation: 292

If you want to plot them altogether using seaborn, you'd better combine two DataFrames first.

low_tenure['cat'] = 'Low tenure'
high_tenure['cat'] = 'High tenure'
df_combined = pd.concat([low_tenure, high_tenure])
sns.countplot(x='Partner', hue='cat', data=df_combined)

Upvotes: 1

Related Questions