Plotting a dataframe as both a 'hist' and 'kde' on the same plot

后端 未结 3 736
心在旅途
心在旅途 2020-12-30 07:08

I have a pandas dataframe with user information. I would like to plot the age of users as both a kind=\'kde\' and on kind=\'hist\' on

3条回答
  •  既然无缘
    2020-12-30 07:50

    It is better and even simpler to use seaborn.displot. Prior proposed solutions had KDE plot appear a little "shifted up" for me. seaborn.distplot accurately lined up zeros between hist and kde plots.
    import seaborn as sns sns.displot(df.a)

提交回复
热议问题