Skip to content

Instantly share code, notes, and snippets.

Created July 8, 2013 23:40
Show Gist options
  • Save anonymous/5953425 to your computer and use it in GitHub Desktop.
Save anonymous/5953425 to your computer and use it in GitHub Desktop.
for saving a file w no borders and making a square around a route.
clf()
fig = figure()
ax = fig.add_subplot(1,1,1)
imshow(img,extent = m_extent, interpolation = 'nearest')
x,y = gps.merc_x(lon),gps.merc_y(lat)
plot(x, y,'r', lw = 3);
buff = 1.1 # creates an extra 10% buffer
ctr_pt = array([max(x)+min(x), max(y)+min(y)])/2.0 # centerpoint
radius = buff*max([max(x)-min(x), max(y)-min(y)])/2.0 # radius of square (side length/2)
axis( ctr_pt[[0,0,1,1]] + radius*array([-1, 1, -1, 1]) )
axis('off')
extent = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
savefig('../../../Desktop/test.png', bbox_inches=extent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment