我有一张银河系的照片,我只想画第500张

2024-09-27 04:20:18 发布

您现在位置:Python中文网/ 问答频道 /正文

该文件是1000乘1000,我想打印所有的x值,但只有我的数据第500行。到目前为止,我的代码是:

import matplotlib.pyplot as plt
from numpy import *
from pylab import *
import scipy.ndimage
from scipy import *

data = fromfile("m33.dat",dtype=int16)
data_fortran=data.reshape((1000,1000),order="FORTRAN")
data2 = scipy.ndimage.filters.gaussian_filter(data_fortran,5,mode="nearest")

#plot m33.dat into a contour plot
plt.imshow(data2,interpolation="none",cmap="binary")
plt.show()

Tags: 文件数据代码fromimportdataplotmatplotlib
1条回答
网友
1楼 · 发布于 2024-09-27 04:20:18
plt.imshow(data2[499].reshape(1,-1),interpolation="none",cmap="binary")

由于Python使用基于0的索引,第500行的索引值为499。你知道吗

相关问题 更多 >

    热门问题