[Basemap] savefig bbox_inches=tight

if one saves a Basemap plot with savefig option
bbox_inches='tight' geographical coordinates
are cut:

bmap = Basemap(...)
bmap.drawparallels([those,numbers,are,gone],
                   labels=[1,0,0,0])
bmap.drawmeridians([those,numbers,are,gone],
                   labels=[0,0,0,1])
plt.contourf(...)
plt.savefig(file, bbox_inches='tight')

is this missbehavior known, or is there a simple
fix for that?

best regards, yoshi

Yoshi:

You can use the pad_inches keyword to adjust the amount of space left around the map.

Try this:

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
bmap = Basemap()
bmap.drawcoastlines()
bmap.drawparallels(np.arange(-90,91,30),
                            labels=[1,0,0,0])
bmap.drawmeridians(np.arange(0,360,60),
                            labels=[0,0,0,1])
plt.savefig('bboxtight.png', bbox_inches='tight',pad_inches=0.45)

-Jeff

···

On 10/27/11 1:41 AM, Yoshi Rokuko wrote:

if one saves a Basemap plot with savefig option
bbox_inches='tight' geographical coordinates
are cut:

bmap = Basemap(...)
bmap.drawparallels([those,numbers,are,gone],
                    labels=[1,0,0,0])
bmap.drawmeridians([those,numbers,are,gone],
                    labels=[0,0,0,1])
plt.contourf(...)
plt.savefig(file, bbox_inches='tight')

is this missbehavior known, or is there a simple
fix for that?

best regards, yoshi

+------------------------------------------- Jeff Whitaker -----------+

You can use the pad_inches keyword to adjust the amount of space left
around the map.

<...>

plt.savefig('bboxtight.png', bbox_inches='tight',pad_inches=0.45)

yes that works fine (0.5 inches in my case).

thank you.