← 返回章节索引

CHAPTER 06 · 作品已接入

移动坐标轴

用 twinx() 添加第二个纵轴,承载不同量纲。

Twin Y Axis
import matplotlib.pyplot as plt

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(x, y1, color='#ff5f9e')
ax2.plot(x, y2, color='#5b9dff')
plt.show()
移动轴任意位置添加定制刻度隐藏轴脊移动坐标轴