How to use twinx()
import modules
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('bmh')
prepare dummy datas
X = np.linspace(1, 10, 100)
y1 = X * 2.0
y2 = -4.0 * X + 25.0
prepare plotting twinx()
fig, ax = plt.subplots(1, 1)
ax2 = ax.twinx()
plot left bar
ax.plot(X, y1)
ax.set_ylim(0, 30)
ax.set_ylabel('y1 for left_bar [Kg]')
plot right bar
ax2.plot(X, y2 ,ls=':', lw=0.5, c='r', alpha=0.3)
ax2.set_ylim(0, 30)
ax2.set_ylabel('y2 for left_bar [m]')
show
ax.set_title('twin_X')
fig
plt.show()