i plot 1 subplot like:
title 1 fig1 fig2 fig3
with common colorbar these 3 figures (1,2,3).
title2 fig4 fig5 fig6
with common colorbar these 3 figures (4,5,6).
i haven't found way add 2 different colorbars on same figure described above.
it's bit tricky, can share sets of subplots common colorbar.
i've drawn on few previous anwers might worth reading well:
matplotlib 2 subplots, 1 colorbar
how can create standard colorbar series of plots in python
and of course, documentation matplotlib:
import numpy np import matplotlib.pyplot plt mpl_toolkits.axes_grid1 import imagegrid # generate random data data_top = np.random.random((3,10,10)) * 5 data_bot = np.random.random((3,20,20)) * 10 fig = plt.figure() grid_top = imagegrid(fig, 211, nrows_ncols = (1, 3), cbar_location = "right", cbar_mode="single", cbar_pad=.2) grid_bot = imagegrid(fig, 212, nrows_ncols = (1, 3), cbar_location = "right", cbar_mode="single", cbar_pad=.2) n in xrange(3): im1 = grid_top[n].imshow(data_top[n], interpolation='nearest', vmin=0, vmax=5) im2 = grid_bot[n].imshow(data_bot[n], cmap=plt.get_cmap('bone'), interpolation='nearest', vmin=0, vmax=10) grid_top.cbar_axes[0].colorbar(im1) grid_bot.cbar_axes[0].colorbar(im2) plt.show()
Comments
Post a Comment