gpt4 book ai didi

python - 在 Python 中更改数组索引

转载 作者:行者123 更新时间:2023-12-01 04:45:25 24 4
gpt4 key购买 nike

我有一个合适的图像。它的数组尺寸为 300 x 8500。当我绘制图像时,它显示 y 轴范围从 0 到 300,x 轴范围从 0 到 8500。如果我想将 x 轴更改为 1385.9-- 1213.9,用python怎么做呢?我不想只更改索引的数据值。目前,在阅读了拟合文件后,我做到了

data_a=[:,:]

implot= plt.imshow(data_a,cmap=plt.cm.afmhot,interpolation='nearest',aspect='auto',origin='lower')

我认为类似 index = 1385.9 - numpy.arange(0,8500,1)*0.02 的东西可以,但索引只允许使用整数或 bool 值。

最佳答案

试试这个

implot= plt.imshow(data_a,cmap=plt.cm.afmhot,
interpolation='nearest',aspect='auto',origin='lower',
extent=[1385.9,-1213.9,0,300])

extent 根据

中的边缘值调整 xy标签
extent = [horizontal_min,horizontal_max,vertical_min,vertical_max]

关于python - 在 Python 中更改数组索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29534504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com