Matplotlib histogram with multiple legend entries

前端 未结 2 1518
一整个雨季
一整个雨季 2020-12-16 14:49

I have this code that produces a histogram, identifying three types of fields; \"Low\", \"medium\" , and \"high\":

import pylab as plt
import pandas as pd


         


        
2条回答
  •  爱一瞬间的悲伤
    2020-12-16 15:27

    According to me you just need to pass the required label as an argument in the hist function, e.g.

    plt.hist(x, bins=20, alpha=0.5, label='my label')
    

    See example also here https://matplotlib.org/examples/statistics/histogram_demo_multihist.html

提交回复
热议问题