Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## Re: [Matplotlib-users] [Basemap] savefig bbox_inches=tight

 Re: [Matplotlib-users] [Basemap] savefig bbox_inches=tight From: Jeff Whitaker - 2011-10-27 12:33:27 ```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 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 ```

 [Matplotlib-users] [Basemap] savefig bbox_inches=tight From: Yoshi Rokuko - 2011-10-27 07:42:39 ```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 ```
 Re: [Matplotlib-users] [Basemap] savefig bbox_inches=tight From: Jeff Whitaker - 2011-10-27 12:33:27 ```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 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 ```
 Re: [Matplotlib-users] [Basemap] savefig bbox_inches=tight From: Yoshi Rokuko - 2011-10-27 12:56:15 ```+------------------------------------------- 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. ```