简体   繁体   中英

Matplotlib Histogram with no lines between the bars

I want to plot a histogram with matplotlib that has lines delineating the histogram, but with no lines between the bars. Something like this:

在此处输入图片说明

How can I do that?

Using plt.hist() , you need to create the histogram using the argument histtype="stepfilled" and set the edgecolor of the patches, which is by default set to None, in order to get the histogram the way you desire:

import numpy as np
import matplotlib.pyplot as plt

data = np.random.randn(10000)

plt.hist(data, histtype="stepfilled", edgecolor='k', linewidth=1.2)

在此处输入图片说明

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