Thanks a bunch JJ. I've been trying to figure that one out all day!

Mathew

On Thu, Apr 1, 2010 at 1:04 PM, Jae-Joon Lee <lee.j.j...@gmail.com> wrote:

> If you're not afraid of contaminating your code with axes_grid toolkit,
>
> instead
>
> cax = fig.add_axes([0.9, 0.1, 0.1, 0.8]) # setup colorbar axes.
>
> try
>
> from mpl_toolkits.axes_grid import make_axes_locatable
> import  matplotlib.axes as maxes
>
> divider = make_axes_locatable(ax)
> cax = divider.new_horizontal("5%", pad=0.05, axes_class=maxes.Axes)
> fig.add_axes(cax)
>
> This way, the height of the colorbar always matches that of your main axes.
>
> Regards,
>
> -JJ
>
>
> On Thu, Apr 1, 2010 at 3:24 PM, Mathew Yeates <mat.yea...@gmail.com>
> wrote:
> > Hi
> >
> > I have a Basemap and I want to manually add a colorbar to the side. As
> you
> > can see in the attached image, the colorbar is not correctly positioned.
> >
> > Here is a snippet of code
> >
> > ax=fig.add_axes([0.1,0.1,0.8,.8])
> > m = Basemap(resolution='c',projection='cyl',lon_0=0,ax=ax)
> >
> > cax = fig.add_axes([0.9, 0.1, 0.1, 0.8]) # setup colorbar axes.
> > cmap = mpl.cm.cool
> > norm = mpl.colors.Normalize(vmin=5, vmax=10)
> > cb1 = mpl.colorbar.ColorbarBase(cax, cmap=cmap,
> >                                        norm=norm,
> >                                        orientation='vertical')
> >
> > what am I doing wrong?
> >
> > Mathew
> >
> >
> ------------------------------------------------------------------------------
> > Download Intel&#174; Parallel Studio Eval
> > Try the new software tools for yourself. Speed compiling, find bugs
> > proactively, and fine-tune applications for parallel performance.
> > See why Intel Parallel Studio got high marks during beta.
> > http://p.sf.net/sfu/intel-sw-dev
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to