- #21 Histogram only | seaborn
- #21 Histogram with Rug
- #21 Custom rug | seaborn
- #21 Custom density | seaborn
By default, the displot function of seaborn plots an histogram with a density curve (see graph #20). You can easily remove the density using the option kde=”False”. You can also control the presence of rugs using rug=”True”. You can custom rug and density as proposed below:
# Import library and dataset import seaborn as sns df = sns.load_dataset('iris') # Hist only sns.distplot( a=df["sepal_length"], hist=True, kde=False, rug=False ) #sns.plt.show() # Hist + Rug + kernel density sns.distplot( a=df["sepal_length"], hist=True, kde=True, rug=True ) #sns.plt.show() # To change parameters of rug sns.distplot( a=df["sepal_length"], rug=True, rug_kws={"color": "r", "alpha":0.3, "linewidth": 2, "height":0.2 } ) # To change parameters of density distribution sns.distplot( a=df["sepal_length"], kde=True, kde_kws={"color": "g", "alpha":0.3, "linewidth": 5, "shade":True } ) #sns.plt.show()
How can i get the line function for the fitted density curve?
Hi,
I know it is a long time that you asked your question but if others do the same, you can get the “line function” by adding this argument : kde=True