You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

3D直方图峰值偏移原点问题排查求助

波函数3D直方图峰值偏移问题排查

我在绘制波函数的直方图时,发现代码生成的3D直方图峰值始终略微偏离理论应处的原点,偏移方向似乎固定,但尚未确认。1D版本代码运行正常,虽2D扩展难度不高,但仍无法排除代码问题。现在需要确认是否是直方图绘制代码导致了这个偏移,请求协助。

xpos和ypos是由Metropolis算法生成的一维位置数组,已省略残差图,附相关图表:2D直方图、3D直方图

"Generate 3D histogram"

hist, xedges, yedges = np.histogram2d(xpos, ypos, bins=bins)
Norm = np.max(Z)/np.max(hist) * hist
#print(xedges)
#print(yedges)
#print(Norm)

"Plotting 3D Histogram (with residuals)"
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})

x, y = np.meshgrid(xedges[:-1]+xedges[1:], yedges[:-1]+yedges[1:])
x = x.flatten()/2
y = y.flatten()/2
z = np.zeros_like(x)

dx = xedges[1] - xedges[0]
dy = yedges[1] - yedges[0]
dz = Norm.flatten()

cmap = cm.get_cmap('viridis')
max_height = np.max(dz)
min_height = np.min(dz)
rgba = [cmap((k-min_height)/max_height) for k in dz]

ax.bar3d(x, y, z, dx, dy, dz, color=rgba, zsort='average')
ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, alpha=0.3, linewidth=0, antialiased=False)


plt.xlabel("x")
plt.ylabel("y")
ax.set_xlim([-3, 3])
ax.set_ylim([-3, 3])
ax.set_zlabel('|' + chr(968) + '|' + chr(178))
#ax.zaxis.set_major_formatter('{x:.02f}')
ax.tick_params(axis='z', labelcolor='red')
#plt.figtext(0.5, 0.01, txt, wrap=True, horizontalalignment='center', fontsize=12)
fig.savefig(dir + '\Images\3Dhist_' + name + '-' + str(t_f) + 's.png')
plt.show()

内容的提问来源于stack exchange,提问作者Dave

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 04:10:17