I have a two boxplotes
JavaScript
x
7
1
a1=a[['kCH4_sync','week_days']]
2
a1.boxplot(by = 'week_days', meanline=True, showmeans=True, showcaps=True, showbox=True,
3
showfliers=False)
4
a2=a[['CH4_sync','week_days']]
5
a2.boxplot(by = 'week_days', meanline=True, showmeans=True, showcaps=True, showbox=True,
6
showfliers=False)
7
But I want to place them in one graph to compare them. Have you any advice to solve this problem? Thanks!
Advertisement
Answer
Use return_type='axes'
to get a1.boxplot
to return a matplotlib Axes
object.
Then pass that axes to the second call to boxplot
using ax=ax
. This will cause both boxplots to be drawn on the same axes.
JavaScript
1
7
1
a1=a[['kCH4_sync','week_days']]
2
ax = a1.boxplot(by='week_days', meanline=True, showmeans=True, showcaps=True,
3
showbox=True, showfliers=False, return_type='axes')
4
a2 = a[['CH4_sync','week_days']]
5
a2.boxplot(by='week_days', meanline=True, showmeans=True, showcaps=True,
6
showbox=True, showfliers=False, ax=ax)
7