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

标签 python matplotlib histogram

我想从我的直方图中删除竖线轮廓,但保留直方图的“ eclipse 刻”,如果可以的话。

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)

给予

enter image description here

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

最佳答案

pyplot.hist() 中,您可以设置 histt​​ype = '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()

示例输出:

enter image description here

关于Python - 从直方图中删除垂直条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39372470/

相关文章:

python - 模型类未声明显式 app_label 并且不在 INSTALLED_APPS 的应用程序中

Python: "import ... as"导致引用不正确

python - 找出只出现一次的词

python - x 轴以日期为刻度

python - Matplotlibrc 需要更新吗?

python - 如何使用不可转换值的默认值执行 df ["col1"].astype(float) ?

python - matplotlib:未显示交互式窗口

c - 在 C 中打印字长直方图

c - 如何为 ncurses 直方图程序缩放图形最小值

c - 3 个骰子的随机骰子卷的星号直方图