2013-11-09 114 views
5

有沒有一種方法可以在matplotlib圖中有最高點和最低點? 有時我有數據隱藏滴答,我想只爲受影響的一方設置滴答。matplotlib頂部底部不同點

以下代碼將影響頂部和底部,或左右兩者。

import matplotlib.pyplot as plt 
fig = plt.figure() 
ax = fig.add_subplot(111) 
ax.plot([0, 1, 3], 'o') 
ax.tick_params(direction = 'out') 
plt.show() 

回答

3

你可以有雙軸線,那麼你可以設置爲單獨每側的屬性:

import matplotlib.pyplot as plt 
fig = plt.figure() 
ax = fig.add_subplot(111) 
ax.plot([0, 1, 3], 'o') 

axR = ax.twinx() 
axT = ax.twiny() 

ax.tick_params(direction = 'out') 
axR.tick_params(direction = 'in') 

ax.tick_params(direction = 'out') 
axT.tick_params(direction = 'in') 

plt.show() 

enter image description here

相關問題