我很難在繪圖中打開和關閉軸,並適當調整軸的大小。我跟着幾個線程,我的方法是: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