What version of matplotlib are you using?
With 0.99.1.1 (and likely later) and also with the svn version, using
the bbox_inches="tight" actually produces an output with too small
margin.
With the svn version, following code should generate an output with an
adequate margin.

Otherwise, you cannot rely on bbox_inches features. Instead, you have
to manually adjust the size of the figure (and subplots_adjust).

Regards,

-JJ


   t1=ax.text(0.5, -0.15, 'Longitude', transform=ax.transAxes,
ha='center', va='center')
   t2=ax.text(-0.1, 0.5, 'Latitude', transform=ax.transAxes, ha=
'center', va='center', rotation='vertical')
   #ax.set_title("Sign.Different: GSPW2 - Princeton")
   fig.savefig('test.png', dpi=300, bbox_inches='tight',
bbox_extra_artists=[t1, t2])



On Tue, Jun 8, 2010 at 7:47 PM, mdekauwe <mdeka...@gmail.com> wrote:
>
> Hi,
>
> when I make plots with the Basemap package I seem to be getting a large
> amount of white space at the top and bottom of the plot, even if I use the
> option bbox_inches='tight'. Does anyone know how I can stop this happening?
>
> Example image...
> http://old.nabble.com/file/p28824528/diffmap_JULES_DJF_snowFrac.GSWP2_vs_SSMI.jpg
>
> What I am currently doing...
>
> def makeMap(image, ofname, imageMin, imageMax, ticks):
>    """ dump out the array as a nice map... """
>    fig = plt.figure(figsize=(8, 6))
>    m = Basemap(projection='cyl', llcrnrlon=-179.5, llcrnrlat=-60.0, \
>                        urcrnrlon=179.5, urcrnrlat=89.5, resolution='c')
>    # add an axes, leaving room for colorbar on the right.
>    ax = fig.add_axes([0.1, 0.1, 0.7, 0.7])
>    m.ax = ax
>    colourmap = plt.cm.RdYlBu
>    colourmap.set_bad('w', 1.0)
>    im = m.imshow(image, colourmap, colors.Normalize(vmin=imageMin,
> vmax=imageMax, clip=False),\
>                           interpolation='nearest')
>    pos = ax.get_position()
>    l, b, w, h = pos.bounds
>    cax = plt.axes([l + w + 0.045, b, 0.05, h])
>    norm = colors.BoundaryNorm(ticks, colourmap.N)
>    cbar = mpl.colorbar.ColorbarBase(cax, cmap=colourmap, norm=norm,
> ticks=ticks)
>    #cbar = plt.colorbar(im, cax=cax)
>    # xlabel and ylabel were overwriting the tick labels so i need to move
> them
>    # transAxes set the position from the bottom left of the axes (1,1 would
> be the top right)
>    ax.text(0.5, -0.15, 'Longitude', transform=ax.transAxes, ha='center',
> va='center')
>    ax.text(-0.1, 0.5, 'Latitude', transform=ax.transAxes, ha= 'center',
> va='center', rotation='vertical')
>    #ax.set_title("Sign.Different: GSPW2 - Princeton")
>    m.drawcoastlines(linewidth=0.2, color='k')
>    m.drawcountries(linewidth=0.1, color='k')
>    #m.drawrivers()
>    m.drawparallels(np.array([-90.0, -60.0, -30.0, 0.0, 30.0, 60.0, 90.0]),
> labels=[1,0,0,1],\
>                           fontsize=10, rotation=20)
>    m.drawmeridians(np.array([-180.0, -120.0, -60.0, 0.0, 60.0, 120.0,
> 180.0]), labels=[0,0,0,1], \
>                            fontsize=10, rotation=20)
>    fig.savefig(ofname + '.png', dpi=300, bbox_inches='tight')
>    # for LaTeX doc...
>    fig.savefig(os.path.join("/users/eow/mgdk/doc/snowy_notes/figures/",
> (ofname + ".eps")), dpi=300,\
>                   bbox_inches='tight')
>
> Many thanks,
>
> Martin
> --
> View this message in context: 
> http://old.nabble.com/Removing-white-space-surrounding-plots-tp28824528p28824528.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to