-2

I have several histograms that I want to include in a single figure. I know I can do this:

plt.title("Mondays")
plt.hist(mon["price"], bins=50, alpha=0.5, histtype='bar', ec='black')
plt.show()

But if I add another plt.hist(...) before calling plt.show(), matplotlib adds the second histogram on top of the first one. I'd like separate subplots for each of mon["price"], tues["price"], ..., sun["price"].

How would I go about that?

anon_swe
  • 8,791
  • 24
  • 85
  • 145
  • Did you look through the [Matplotlib gallery](https://matplotlib.org/gallery/index.html) for figures with multiple sub-plots and try to adapt the example code to your purpose? – wwii Mar 13 '18 at 22:52

1 Answers1

0

You can use subplots as in this example: matplotlob documentation 2 plots

plt.subplot(211) means: 2 rows, 1 column, 1:this is the 1st plot.

Here is an example with 4 plots: 2 rows and 2 columns: 4 plots

gabBGG
  • 21
  • 3