我的代码的重要部分是使行的最大值从3500埃(天文单位)到7000埃不等。但是,我的函数正在调用的最大值超出了范围。如何在文件中调用一定范围的行?
%matplotlib notebook
import numpy as np #import python tools
import matplotlib.pyplot as plt
import math
file1 = 'spectra1.dat' #call the first file
spectra1 = np.loadtxt(file1, skiprows=3)
fig= plt.figure() #plotting the data for the figure below
plt.title('spectral atlas', fontname="times new roman", fontsize=15)
#title
axes=fig.add_subplot(111) #create dimensions for graph
plt.ylabel('Normalized Flux ', fontname="times new roman") #Label for Y axis
plt.xlabel('Wavelength ($\AA$)', fontname="times new roman") #Label for X axis
plt.xlim(3500,7000)
plt.ylim(0,3)
ymax = max(spectra1[:,1])
print(ymax)
norminc1 = (spectra1[:,1]/ymax)+1
axes.plot(spectra1[:,0], norminc1, label= 'normalized flux of spectra1')
plt.legend(loc=1, prop={'size': 7}) #create legend, moving it to top right and decreasing size
plt.show()