Python Matplotlib.hist-使用阶跃直方图平滑点之间的直线

Python Matplotlib.hist-使用阶跃直方图平滑点之间的直线,python,matplotlib,Python,Matplotlib,我正在努力使各点之间的界线变得平滑。增加垃圾箱的数量是一种方法,但根据我的实际数据,这仍然不能解决问题 def plotstep_test(x, y, z): plt.figure(figsize=[10, 6]) plt.hist([x, y, z], color=['red','black', 'green'], histtype='step', bins=20) plt.gca().spines['right'].set_color('none') pl

我正在努力使各点之间的界线变得平滑。增加垃圾箱的数量是一种方法,但根据我的实际数据,这仍然不能解决问题

def plotstep_test(x, y, z):

    plt.figure(figsize=[10, 6])
    plt.hist([x, y, z], color=['red','black', 'green'], histtype='step', bins=20)

    plt.gca().spines['right'].set_color('none')
    plt.gca().spines['top'].set_color('none')

    plt.title('', fontsize=14)
    plt.xlabel('', fontsize=14, labelpad=5)
    plt.ylabel('', fontsize=14, labelpad=5)


    plt.xticks(np.arange(0, 1.1, step=0.1), fontsize=12)    
    plt.yticks(fontsize=12)
    plt.tick_params(axis='both', which='both', left=True, bottom=True,labelbottom=True) 


    plt.show()
随机数:

plotstep_test(np.random.uniform(size=10), np.random.uniform(size=5), np.random.uniform(size=50))

听起来你可能更喜欢直方图。然后,您将完全控制估计的平滑度

尝试:

这将为您提供:

如果你喜欢这条线的外观,你可以让你的其他东西工作没有问题,我相信

一般来说,
seaborn
制作的统计图非常漂亮

data = np.random.normal(size=100)
import seaborn as sns
sns.distplot(data)