我很难在绘图中打开和关闭轴,并适当调整轴的大小。我跟着几个线程,我的方法是:Matplotlib轴控制
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')
但我的数字仍然在顶部和右侧,和一个陌生的差距轴最终由于轴的尺寸。
我不能完全确定你想要达到的目标,但在matplotlib网站上有[some](http://matplotlib.org/examples/ticks_and_spines/spines_demo_bounds.html)[示例](http://matplotlib.org/examples/ticks_and_spines/spines_demo.html),可以帮助你。 – Evert