Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting 2 seaborn KDE joint plots in the same row

Is there a way to plot two KDE joint plots side by side? I have been able to display almost everyt type of graphs that seaborn can produce using something like this:

power_t_series = sDF.pitch
velocity_t_series = sDF.velocity
duration_t_series = sDF.duration

figure, axes = plt.subplots(nrows=1, ncols=2)
figure.set_size_inches(20,10)
b, g = sns.color_palette("muted", 2)

sns.tsplot(power_t_series, color = b, ax=axes[0])
sns.distplot(power_t_series, color = r, ax=axes[1])

But when specifying jointplot, is top-down the only way to display multiple charts of this nature? Here is the code and the error:

figure, axes = plt.subplots(nrows=1, ncols=2)
figure.set_size_inches(20,10)
b, g = sns.color_palette("muted", 2)

sns.jointplot(power_t_series, velocity_t_series, kind='kde', ax=axes[0])
sns.jointplot(power_t_series, duration_t_series, kind='kde', ax=axes[1])

I get this:

      3 b, g = sns.color_palette("muted", 2)
      4 
----> 5 sns.jointplot(power_t_series, velocity_t_series, kind='kde', ax=axes[0])
      6 sns.jointplot(power_t_series, duration_t_series, kind='kde', ax=axes[1])

TypeError: jointplot() got an unexpected keyword argument 'ax' 

Is there any way to plot this type of chart side by side, since ax is not an argument accepted by jointplot()?

like image 317
Luis Miguel Avatar asked Sep 14 '14 23:09

Luis Miguel


1 Answers

jointplot is a figure-level function and can't coexist in a figure with other plots, but there is the kdeplot function which can draw a 2-d KDE onto a specific Axes. See this example.

like image 124
mwaskom Avatar answered Oct 22 '22 17:10

mwaskom