Multiple histograms in Pandas

后端 未结 5 1420
攒了一身酷
攒了一身酷 2020-12-05 06:59

I would like to create the following histogram (see image below) taken from the book \"Think Stats\". However, I cannot get them on the same plot. Each DataFrame takes its o

5条回答
  •  北海茫月
    2020-12-05 07:59

    Here is the snippet, In my case I have explicitly specified bins and range as I didn't handle outlier removal as the author of the book.

    fig, ax = plt.subplots()
    ax.hist([first.prglngth, others.prglngth], 10, (27, 50), histtype="bar", label=("First", "Other"))
    ax.set_title("Histogram")
    ax.legend()
    

    Refer Matplotlib multihist plot with different sizes example.

提交回复
热议问题