import numpy as np
import pandas as pd
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.title('样本1')
plt.xlabel('波数')
plt.ylabel('吸光度')
xmajorLocator = MultipleLocator(500)
xmajorFormatter = FormatStrFormatter('%1f')
xminorLocator = MultipleLocator(1)
ymajorLocator = MultipleLocator(0.05)
ymajorFormatter = FormatStrFormatter('%1f')
yminorLocator = MultipleLocator(0.001)
plt.xlim([650,4000])
plt.ylim([-0.06,0.95])
plot1=dt2.plot(linewidth=0.5)#dt2是要画的图的数据
plot1.legend_.remove()
https://blog.csdn.net/qq_44702847/article/details/105215000
https://blog.51cto.com/yunyaniu/2912319
不是图例的错误,关于图例的错误已解决
我也是这个问题,后来我把调整刻度挪到画图后面就好了