這是我繪製殘差圖的代碼;然而,我已經失去了我的X軸刻度數字,我不知道如何讓他們回來......任何幫助將不勝感激。對不起,如果這個線程的格式不對,這是我的第一個。我已經在圖表的x-ticks上丟失了數字,我該如何回覆它們?
代碼:
pyplot.figure()
fig1 = plt.figure(1)
frame1=fig1.add_axes((.1,.3,.8,.6))
pyplot.errorbar(xval, yval, yerr=yerr, xerr=xerr, marker='o',markersize = 2, linestyle='None', color = 'black')
# Axis labels
pyplot.xlabel(' Height (m)')
pyplot.ylabel('Mass per second (kg.s-1)')
# Generate best fit line using model function and best fit parameters, and add to plot
fit_line=model_funct(xval, [a_soln, b_soln])
# Theoretical line
x = np.array(arange(0.07,0.15, 0.001))
y = (-2.61049E-05) + (0.005815772)*x
plt.plot(x, y, linestyle = '--', color ='r',linewidth = 0.7, label = 'Theoretical')
# Experimental line
s = (-4.43329E-05) + (0.006008837)*x
pyplot.plot(x, s,linewidth = 0.7, color = 'black', label = 'Experimental Chi Squared Fit')
# Set suitable axis limits: you will probably need to change these...
pyplot.xlim(0.08, 0.14)
pyplot.ylim(0.0004, 0.0008)
pyplot.legend(loc = 'upper left',prop={'size':10})
frame2=fig1.add_axes((.1,.1,.8,.2))
difference = y - s
pyplot.plot(x, difference, color = 'black')
frame2.set_ylabel('Residual')
plt.xlabel('Height (m)')
plt.yticks(numpy.arange(-0.000010, 0.000010, 0.00001))
plt.xticks(numpy.arange(0.08, 0.14, 0.01))
pyplot.ylim(-0.000010, 0.000010)
pyplot.xlim(0.08,0.14)
pyplot.grid()
pyplot.show()
如果你提供的一個小例子,這將是有益的工作代碼(https://stackoverflow.com/help/mcve)您提供的代碼與格式混合,不包含'import'語句,並引用未定義的變量,例如'xval'。 – Gus