作为模拟通过孔径的衍射的长程序的一部分,我正在摆弄尝试得到我的结果plt.imshow()
使其原点位于绘图的中心,即我希望更改轴。
相关代码部分是:
n=40
lam=0.0006
k=(2*np.pi)/lam
z=float(input("Type screen distance, z in mm: "))
rho=float(input("Type rho in mm: "))
delta = 2/n
intensity = np.zeros((n+1,n+1))
for i in range(n+1):
x=-1+(i*delta)
for j in range(n+1):
y =-1+(j*delta)
intensity[i,j] = (abs(square_2dsimpson_eval(-rho/2,rho/2,n)))**2
plt.imshow(intensity)
plt.show()
generating the below plot. Thanks in advance.
![enter image description here](https://i.stack.imgur.com/xpFly.png)
为了将原点定位在图像图的中心,您可以使用对称extent
.
import numpy as np
import matplotlib.pyplot as plt
x = np.array([[1,2,1,4],[2,5,3,1],[0,1,2,2]])
plt.imshow(x, extent=[-x.shape[1]/2., x.shape[1]/2., -x.shape[0]/2., x.shape[0]/2. ])
plt.show()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)