<Python, matplotlib> 2nd Y axis
2番目のY軸Secondary Y-axis
を書く方法。
In [1]: import numpy as np ...: import matplotlib.pyplot as plt ...: x = np.arange(0, 10, 0.1) ...: y1 = 0.05 * x**2 ...: y2 = -1 *y1 ...: ...: fig, ax1 = plt.subplots() ...: ...: ax2 = ax1.twinx() ...: ax1.plot(x, y1, 'g-') ...: ax2.plot(x, y2, 'b-') ...: ...: ax1.set_xlabel('X data') ...: ax1.set_ylabel('Y1 data', color='g') ...: ax2.set_ylabel('Y2 data', color='b') ...: ...: plt.show() ...:
教えてもらったとこ。
StackOverflow
stackoverflow.com
マニュアル
api example code: two_scales.py — Matplotlib 1.5.0 documentation