我很难在绘图中打开和关闭轴,也很难调整轴的大小。我关注了几个线程,我的方法是:
f1=plt.figure(1,(3,3))
ax=Subplot(f1,111)
f1.add_subplot(ax)
ax.scatter(current,backg,label='Background Height')
ax.plot(current,backg)
ax.scatter(current,peak,color = 'red',label='Peak Spot Height')
ax.plot(current,peak,color='red')
ax.plot(current,meanspot,color='green')
ax.scatter(current,meanspot,color = 'green',label='Mean Spot Height')
ax.spines['left'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
但是我的图形最终仍然在顶部和右侧带有轴,并且由于轴的大小而出现了奇怪的间隙。