有没有办法可以将直方图与该图中的函数图对齐?

Is there a way I can align the histogram with the function plot in this graph?

这是我目前的情节:(使用Python)

深橙色曲线是我的函数,生成自

plt.plot(x,Yt,color = 'darkorange')

而直方图来自

plt.bar(dic.keys(), dic.values(), width=np.abs((rang2-rang1)/N), color='lightcoral') 

从这个图中我们可以看到它们在底部没有完全对齐(它们都应该是 0),我想知道有没有办法让它们对齐?谢谢!!

您可能需要尝试使用下面的偏移量

offset = 0.01


Yt = [y-offset for y in Yt]

plt.plot(x,Yt,color = 'darkorange')

请注意,如果您只想在函数的峰值范围之外进行偏移(中间的尖峰部分),则需要非常量偏移。