文件是 1000 x 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()
请您参考如下方法:
plt.imshow(data2[499].reshape(1,-1),interpolation="none",cmap="binary")
由于 Python 使用基于 0 的索引,第 500 行将在索引值 499 处找到。
