From: Jae-Joon L. <lee...@gm...> - 2010-11-22 04:48:54
|
On Thu, Nov 18, 2010 at 11:10 PM, John <was...@gm...> wrote: > 1) I only need one colorbar, how would I create a single colorbar on > the right that spanned across all axes? (ie. same height as the stack) There are a few options you can try. I guess the easiest way is setting up the axes manually. dy = 0.8/3. ax1 = axes([0.1, 0.1, 0.8, dy]) ax2 = axes([0.1, 0.1+dy, 0.8, dy]) ax3 = axes([0.1, 0.1+2*dy, 0.8, dy]) sc = ax1.scatter([1,2],[3,4], c=[0,1], cmap="jet") cax = axes([0.9, 0.1, 0.03, 0.8]) plt.colorbar(sc, cax=cax) Also, you make take a look at the axes_grid1 toolkit. (see e.g, http://matplotlib.sourceforge.net/examples/axes_grid/demo_axes_grid.html) > 2) is there a way to place the colorbar in the bottom middle of my > panels (if I end up with more than one)? Use loc=8. > 3) How can I customize the tick labels of the colorbar? You may use "set_ticks" and "set_ticklabels" method of the colorbar object. cb = plt.colorbar(a.collections[0],cax=ia,orientation='horizontal') cb.set_ticks([-100,0,100]) cb.set_ticklabels(["-100", "0", "+100"]) Also, locators and formatter can be specified during colorbar creation (take a look at the doc). -JJ |