Python - 从直方图中删除垂直条线

iro*_*man 3 python matplotlib histogram

我想从直方图中删除垂直条纹轮廓,但保留直方图的"蚀刻",如果这样做的话.

import matplotlib.pyplot as plt
import numpy as np  

bins = 35

fig = plt.figure(figsize=(7,6))
ax = fig.add_subplot(111)

ax.hist(subVel_Hydro1, bins=bins, facecolor='none', 
        edgecolor='black', label = 'Pecuiliar Vel')
ax.set_xlabel('$v_{_{B|A}} $ [$km\ s^{-1}$]', fontsize = 16)
ax.set_ylabel(r'$P\ (r_{_{B|A}} )$', fontsize = 16)
ax.legend(frameon=False)
Run Code Online (Sandbox Code Playgroud)

给予

在此输入图像描述

这在matplotlibs直方图功能中是否可行?我希望我提供了足够的清晰度.

Tua*_*nDT 5

pyplot.hist()你可以设置的值histtype = 'step'.示例代码:

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

x = np.random.normal(0,1,size=1000)

fig = plt.figure()
ax = fig.add_subplot(111)

ax.hist(x, bins=50, histtype = 'step', fill = None)



plt.show()
Run Code Online (Sandbox Code Playgroud)

样本输出:

在此输入图像描述