Skip to content Skip to sidebar Skip to footer

How To Plot 2 Subplots That Share The Same X-axis

So currently i have a scatterplot and a kdeplot that i used seaborn library to plot out. Here is how i plotted the graphs: # plot a graph to see the zipcodes vs the density plt.f

Solution 1:

Yep! Credits to @DavidG, i managed to plot out the subplots properly. So i added the axes object into the respective graphs. Here it goes.

f, axarr = plt.subplots(2, figsize=(16,8), sharex=True)
sns.kdeplot(king['zipcode'], shade=True, legend=False,ax=axarr[0])
axarr[0].set_ylabel('Density')
sns.scatterplot(x=king['zipcode'],y=king['price'],ax=axarr[1])
plt.show()

And it results in this: .

Post a Comment for "How To Plot 2 Subplots That Share The Same X-axis"