Reputation: 51
I am unable to display two distplots next to each other, when plotted alone both work fine.
f, (ax1, ax2) = plt.subplots(1,2)
sns.distplot(df_reqd_data_0['Total_Hood_Group_Earnings'], ax=ax1)
plt.show()
sns.distplot(df_reqd_data_0['Total_Partner_Earnings'], ax=ax2 )
plt.show()
Upvotes: 1
Views: 1302
Reputation: 3461
You need to call the plot.show()
command once after both the distplot
commands.
Remove the extra plot.show()
, so that the code looks like this.
f, (ax1, ax2) = plt.subplots(1,2)
sns.distplot(df_reqd_data_0['Total_Hood_Group_Earnings'], ax=ax1)
sns.distplot(df_reqd_data_0['Total_Partner_Earnings'], ax=ax2 )
plt.show()
EDIT:
Apart from the extra plt.show()
, I am not sure what is sns
here. But just to illustrate my point and answer the question posted by the OP:
"How to can display two distplots next to each other?"
try this code,
import matplotlib.pyplot as plt
x = range(10)
y = range(10)
plt.subplot(2,1,1)
plt.plot(y)
plt.subplot(2,1,2)
plt.plot(x)
plt.show()
and you can see why it works.
Upvotes: 1