0
我正在針對固定x軸繪製兩個numpy陣列,分別稱爲line1和line2。一個陣列將被繪製在對數圖中,使用半對數並且另一個陣列被繪製在相同x軸上的基本線性圖中。如果一個繪圖是線性的,另一個是對數,則在雙Y軸繪圖中兩個y軸的刻度間隔均爲對數
這兩個y軸的縮放格式似乎都很好。然而,右側線性圖(第2行)的y軸刻度間隔和刻度似乎是對數(間隔較近的刻度),我似乎無法找到改變它的方法。
有沒有辦法將下圖中的右側y軸更改爲線性?
這裏是我的代碼:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0.01, 10.0, 0.01)
y = np.exp(x)
y2 = np.sin(2*np.pi*x)
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
line1 = ax1.semilogy(x,y)
ax2 = fig1.add_subplot(111, sharex=ax1, frameon=False)
line2 = ax2.plot(x,y2,"r")
#MATPLOTLIB BUG? THE SECOND Y AXES HAS A LOG SCALE AND THE TICK LABELS CAN'T BE CHANGED
ax2.set_yscale('linear')
ax2.yaxis.tick_right()
plt.show()