@@ -610,10 +610,10 @@ def close(*args):
610610 _pylab_helpers .Gcf .destroy (arg )
611611 elif isinstance (arg , Figure ):
612612 for manager in _pylab_helpers .Gcf .get_all_fig_managers ():
613- if manager .figure == arg :
613+ if manager .canvas . figure == arg :
614614 _pylab_helpers .Gcf .destroy (manager .num )
615615 else :
616- error_msg ('Unrecognized argument type to close' )
616+ error_msg ('Unrecognized argument type %s to close' % type ( arg ) )
617617 else :
618618 error_msg ('close takes 0 or 1 arguments' )
619619
@@ -757,6 +757,15 @@ def figlegend(handles, labels, loc, **kwargs):
757757 l = gcf ().legend (handles , labels , loc , ** kwargs )
758758 draw_if_interactive ()
759759 return l
760+
761+ def savefig (* args , ** kwargs ):
762+ try : ret = gcf ().savefig (* args , ** kwargs )
763+ except RuntimeError , msg :
764+ msg = raise_msg_to_str (msg )
765+ error_msg (msg )
766+ raise RuntimeError (msg )
767+ else : return ret
768+ savefig .__doc__ = Figure .savefig .__doc__
760769
761770
762771def figure (num = None , # autoincrement if None, else integer from 1-N
@@ -767,23 +776,27 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
767776 frameon = True ,
768777 ):
769778 """
770- figure(num = 1, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
779+ figure(num = None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
780+
771781
782+ Create a new figure and return a handle to it. If num=None, the
783+ figure number will be incremented and a new figure will be
784+ created.
772785
773- Create a new figure and return a handle to it
774786
775- If figure(num) already exists, make it active and return the
776- handle to it.
787+ If num is an integer, and figure(num) already exists, make it
788+ active and return the handle to it. If figure(num) does not exist
789+ it will be created. Numbering starts at 1, matlab style
777790
778791 figure(1)
779792
780- If num=None, the figure number will be incremented and a new
781- figure will be created.
782-
783- figsize - width in height x inches; defaults to rc figure.figsize
784- dpi - resolution; defaults to rc figure.dpi
785- facecolor - the background color; defaults to rc figure.facecolor
786- edgecolor - the border color; defaults to rc figure.edgecolor
793+
794+ kwargs:
795+
796+ figsize - width in height x inches; defaults to rc figure.figsize
797+ dpi - resolution; defaults to rc figure.dpi
798+ facecolor - the background color; defaults to rc figure.facecolor
799+ edgecolor - the border color; defaults to rc figure.edgecolor
787800
788801 rcParams gives the default values from the .matplotlibrc file
789802
@@ -1019,28 +1032,6 @@ def save(fname, X, fmt='%1.4f'):
10191032 if origShape is not None :
10201033 X .shape = origShape
10211034
1022- def savefig (* args , ** kwargs ):
1023- """
1024- SAVEFIG(fname, dpi=150, facecolor='w', edgecolor='w',
1025- orientation='portrait'):
1026-
1027- Save the current figure to filename fname. dpi is the resolution
1028- in dots per inch.
1029-
1030- Output file types currently supported are jpeg and png and will be
1031- deduced by the extension to fname
1032-
1033- facecolor and edgecolor are the colors os the figure rectangle
1034-
1035- orientation is either 'landscape' or 'portrait' - not supported on
1036- all backends; currently only on postscript output."""
1037-
1038- for key in ('dpi' , 'facecolor' , 'edgecolor' ):
1039- if not kwargs .has_key (key ):
1040- kwargs [key ] = rcParams ['savefig.%s' % key ]
1041-
1042- manager = get_current_fig_manager ()
1043- manager .canvas .print_figure (* args , ** kwargs )
10441035
10451036class _ObjectInspector :
10461037
0 commit comments