How do I generate multiple boxplots in one figure with pyplot instead of seaborn?

Screen Link:

The solution notebook shows how to solve this project question using seaborn, and I was wondering if I can just use pyplot instead.

My Code: = 'CountryLive', y = 'money_per_month')
plt.xticks(range(4), ['US', 'UK', 'India', 'Canada'])

What I expected to happen:
I expected to see four boxplots in a figure similar to this:
Screen Shot 2022-11-06 at 5.56.13 PM

What actually happened:
The code seems to generate only one boxplot in the figure:
Screen Shot 2022-11-06 at 5.27.55 PM

How should i code to generate the plot like the solution using pyplot? Should I use subplots?

Hi @leezoe1008

Yes, you have to use subplots, otherwise you are only changing the name/value of the y axis.
A huge advantage of using pyplot and subplots is that you can use different ranges for each box, so you can show the distribution way better

I recommend you to read this

Good luck!

1 Like