Turning off the frame/border

Hello again,

I am not sure if this is a matplotlib question, or a basemap one. The
sample code I found on Google for this either broke my script or
didn't change the end result.

I am attempting to turn the border (frame?) off altogether. Here is
the script, with some sections kept out for brevity:

···

----

import sys
import matplotlib
matplotlib.use('agg')

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(2.56,2.56),dpi=70,frameon=False,linewidth=0)
fig.set_frameon(False)

# as you can see, above are some of attempts at turning the border off

plt.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=None, hspace=None)

m = Basemap(....)

m.drawcoastlines()
fig.savefig("test.png")

-----

Thank you in advance once again!

~ Jeremy

I'm assuming you're talking about turning off the frame around each axes (but maybe you're talking about something else?). The "frameon" attribute in your example code alters the background of the figure canvas, not the borders surrounding each axes.

There's probably a shorter way, but I have a small function that I use to turn off the frame or border around an axes.

def clear_frame(ax=None):
    if ax is None:
        ax = plt.gca()
    ax.xaxis.set_visible(False)
    ax.yaxis.set_visible(False)
    for spine in ax.spines.itervalues():
        spine.set_visible(False)

Best,
-T

···

On Sep 29, 2010, at 1:06 PM, Jeremy Lounds wrote:

Hello again,

I am not sure if this is a matplotlib question, or a basemap one. The
sample code I found on Google for this either broke my script or
didn't change the end result.

I am attempting to turn the border (frame?) off altogether. Here is
the script, with some sections kept out for brevity:

Hi Tony,

Thanks, that works pretty good!

However... it seems that "drawcoastlines" creates a border if I am not
"zoomed out" far enough. (i.e., the coastline is out of bounds).

Do you know how I could turn that off?

Thanks again!

~ Jeremy

···

On Wed, Sep 29, 2010 at 1:21 PM, Tony S Yu <tsyu80@...149...> wrote:

On Sep 29, 2010, at 1:06 PM, Jeremy Lounds wrote:

I am attempting to turn the border (frame?) off altogether. Here is
the script, with some sections kept out for brevity:

I'm assuming you're talking about turning off the frame around each axes (but maybe you're talking about something else?). The "frameon" attribute in your example code alters the background of the figure canvas, not the borders surrounding each axes.

There's probably a shorter way, but I have a small function that I use to turn off the frame or border around an axes.

def clear_frame(ax=None):
if ax is None:
ax = plt.gca()
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
for spine in ax.spines.itervalues():
spine.set_visible(False)

Best,
-T

I'm glad that worked for you. Unfortunately, I don't use basemap, so I can't really help with this additional complication. I'm sure someone else on the list will be able to help you out, though.

Best,
-Tony

···

On Sep 29, 2010, at 2:00 PM, Jeremy Lounds wrote:

On Wed, Sep 29, 2010 at 1:21 PM, Tony S Yu <tsyu80@...149...> wrote:

On Sep 29, 2010, at 1:06 PM, Jeremy Lounds wrote:

I am attempting to turn the border (frame?) off altogether. Here is
the script, with some sections kept out for brevity:

I'm assuming you're talking about turning off the frame around each axes (but maybe you're talking about something else?). The "frameon" attribute in your example code alters the background of the figure canvas, not the borders surrounding each axes.

There's probably a shorter way, but I have a small function that I use to turn off the frame or border around an axes.

def clear_frame(ax=None):
   if ax is None:
       ax = plt.gca()
   ax.xaxis.set_visible(False)
   ax.yaxis.set_visible(False)
   for spine in ax.spines.itervalues():
       spine.set_visible(False)

Best,
-T

Hi Tony,

Thanks, that works pretty good!

However... it seems that "drawcoastlines" creates a border if I am not
"zoomed out" far enough. (i.e., the coastline is out of bounds).

Do you know how I could turn that off?

Thanks again!

~ Jeremy