我的Python代碼與下面的示例類似,用於刪除使用Matplotlib創建的圖的頂部和右側軸。所有繪圖軸上的刻度線也被刪除。刪除所有Matplotlib數字的頂部和右側軸
py.close('all')
py.figure(1)
py.plot(x1, y1)
py.grid()
py.figure(2)
py.plot(x2, y2)
py.grid()
py.figure(3)
py.plot(x3, y3)
py.grid()
ax = py.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
py.tick_params(axis='both', bottom='off', top='off', left='off', right='off')
py.show()
不幸的是,所需的效果只適用於最後一幅情節圖。要刪除頂部/右軸和刻度線的所有數字,我必須把下面的代碼中的每個數字後:
ax = py.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
py.tick_params(...)
是否可以自定義的所有數字軸一次使用Matplotlib?
我看了'rcParams',但沒有辦法隱藏頂部和右側的軸或關閉所有刻度標記。 – wigging
Seaborn的'despine()'方法(參見[這個鏈接](http://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.despine.html#seaborn.despine)關閉了頂軸和右軸。相同的鏈接(請參閱「搜索式樣的重寫元素」部分),它解釋瞭如何使刻度標記不可見(基本上,將它們的大小設置爲0) – jorgeh
有沒有辦法在不使用Seaborn的情況下執行此操作? – wigging