python - How do I get multiple scales for multiple subplots? -
i know multiple scales single plot can use:
fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.plot(range(0,20,2)) ax2.plot(range(10))
however, need 4 subplots. when try like:
fig, ax = plt.subplots(nrows=2, ncols=2) row in ax: col in row: fig1, ax1 = col.subplots() ax2 = ax2.twinx() ax1.plot(range(0,20,2) ax2.plot(range(10))
i error
'axessubplot' object has no attribute 'subplots'
, makes sense, don't know how fix it.
in code question, col
axes create twin axes, i.e. ax2 = col.twinx()
.
fig, ax = plt.subplots(nrows=2, ncols=2) row in ax: col in row: ax2 = col.twinx() col.plot(range(0,20,2) ax2.plot(range(10))
Comments
Post a Comment