**
Matplotlib学习笔记——主次坐标轴
**
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 10, 0.1)
y1 = 0.5 * x ** 2
y2 = -1 * y1
fig, ax1 = plt.subplots() # 使用subplots
ax2 = ax1.twinx() # 镜像ax1,得到ax2的y轴
ax1.plot(x, y1, 'g')
ax2.plot(x, y2, 'b')
ax1.set_xlabel('x')
ax1.set_ylabel('y1', color='g')
ax2.set_ylabel('y2', color='b')
plt.show()