matplotlib - 在 imshow 中绘图未正确采用 x 值
问题描述
我有以下二维绘图代码。我从文件中读取数据并附加它们。在我将它们转换为数组之后。它绘制但没有正确采用 theta_min 和 theta_mix。作为 x 值,它仅采用所需值的位置,而不采用值本身。请建议。
谢谢你的帮助。
import numpy as np
import matplotlib.pylab as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
Filename='DS_MNASP_12_RT-483K_'
FileExtension= '.dat'
FileNumberBegin =1
FileNumberEnd =10
theta_min=1
theta_max=10
RT = 290
HT=523
Filenames = []
for i in range(FileNumberBegin,FileNumberEnd + 1):
Filenames.append(Filename + (4-len(str(i)))*'0' + str(i) + 'p' +
FileExtension)
data=[]
for j in Filenames:
data.append(np.genfromtxt(j, dtype='float', skip_header=41))
d=np.array(data)
ylabel = '$Temperature\/(k)$'
xlabel = '$2\/theta (degrees)$'
x = d[0,theta_min:theta_max,0]
y = (np.arange(RT,HT+1, dtype='float64'))
z = d[:,theta_min:theta_max,1]
X,Y = plt.meshgrid(x, y)
Z = z
xmin = theta_min
xmax = theta_max
im = plt.imshow(Z, origin='lower', aspect='auto', extent=[xmin, xmax, y[0],
y[-1]])
ax = plt.gca()
ax.set_autoscale_on(False)
ax.set_xlabel(xlabel, fontsize = 30)
ax.set_ylabel(ylabel, fontsize = 30)
ax.tick_params(labelsize=20, pad =7, direction='out', width=2, top='off',
right='off')
plt.tight_layout()
plt.show()
解决方案
推荐阅读
- ruby-on-rails - 日期为星期一的 Rails
- docker - 在 Docker Golang SDK imagePull 方法中传递本地 docker 镜像
- html - 如何定位多个信息块彼此之间和页面之间的关系
- docker - 通过脚本重命名普罗米修斯中的图例标签?
- javascript - 带有 JS 的 HTML 在某些浏览器中无法正常工作
- python - Beautifulsoup4 查找并按名称列出孩子
- merge - 使用 Ansible 合并两个数据结构
- gdb - 如何使用 gdb 获取 xmm0 注册原始数据?
- discord - 如何连接到 solana discord 开发者频道?
- node.js - Mongoose (6.x) 保存后填充