我正在使用两个y轴绘制图形,但我无法找到一种修改第二个y轴刻度的方法。没有出现错误,但右侧的刻度根本没有改变。
import matplotlib.pyplot as plt
x = [x for x in range(11)]
y1 = [x for x in range(0, 101, 10)]
y2 = [x for x in range(20, 31, 1)]
fig, ax1 = plt.subplots()
ax2 = plt.twinx()
ax1.plot(x, y1)
ax2.plot(x, y2)
for tick in ax1.yaxis.get_major_ticks():
tick.label.set_fontsize(30)
tick.label.set_color('purple')
for tick in ax2.yaxis.get_major_ticks():
tick.label.set_fontsize(30)
tick.label.set_color('green')
plt.show()