簡體   English   中英

matplotlib:y標注在輔助y軸上,帶有手動刻度線放置

[英]matplotlib: ylabel on the secondary y-axis with manual tick placing

我想在matplotlib的輔助y軸上有一個y標簽。 我知道, twinx()幾乎可以完成以下操作:

ax2 = twinx(ax1)
ax2.set_ylabel('some thing')

但是,我的ax1具有非標准的刻度線放置,並且重復的ax2不會復制該屬性,因此我將不得不再次顯式調整刻度線。

有一個更好的方法嗎?

盡管我還沒有找到如何在單個子圖上標注兩個軸的方法,但是我找到了一個軸矩陣的解決方案:

fig, axs = subplots(2, 2, sharex=True, sharey=True)
axs[0, 0].set_ylabel('on the left by default')
axs[0, 1].yaxis.set_label_position('right')
axs[0, 1].set_ylabel('...now on the right y-axis')

希望這對其他人也有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM