subplot - Python: add y labels on both sides of plot -
i have series of 8 subplots, sharing x-axis , sharing 1 colorbar:
f, ax = plt.subplots(8, sharex=true) in range(8): data = np.random.random((100,100)) im = ax[i].pcolormesh(data) ax[i].set_ylabel(i) f.colorbar(im, ax=ax.ravel().tolist(), orientation='vertical')
i want add second y-label on right side of of these plots; lets want label them a-h.
i attempted adding empty parasite axis each subplot. fails when adding colorbar in end. ylabel_2 = ['a','b','c','d','e','f','g','h']
f, ax = plt.subplots(8, sharex=true) in range(8): data = np.random.random((100,100)) im = ax[i].pcolormesh(data) ax[i].set_ylabel(i) ax2 = ax[i].twinx() ax2.set_ylabel(ylabel_2[i]) ax2.yaxis.set_major_locator(plt.nulllocator()) f.colorbar(im, ax=ax.ravel().tolist(), orientation='vertical')
what best way accomplish want?
Comments
Post a Comment