简体   繁体   中英

How can remove the gaps between bars?

The code underneath works but my problem is that it prints spaces in between the bars in the histogram and I want zero space in between each bin. Any suggestion is appreciated - appreciation!

sns.histplot(stat='frequency',data=df, x="Water",color = "red", bins=10,
             alpha = 0.3, kde = True, line_kws = {'color':'red','linestyle': 'dashed'})

在此处输入图像描述

I want something like the below plot.

在此处输入图像描述

Using edgecolor , which is passed through to Axes.bar . As an example:

import seaborn as sns
tips = sns.load_dataset('tips')

sns.histplot(stat='frequency', data=tips, x='total_bill', color='red', 
             kde=True, alpha=0.3, edgecolor=None, 
             line_kws = {'color':'red','linestyle': 'dashed'})

在此处输入图像描述

Or if you want an edge, then:

edgecolor='red'

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM