@@ -610,10 +610,10 @@ def close(*args):
610
610
_pylab_helpers .Gcf .destroy (arg )
611
611
elif isinstance (arg , Figure ):
612
612
for manager in _pylab_helpers .Gcf .get_all_fig_managers ():
613
- if manager .figure == arg :
613
+ if manager .canvas . figure == arg :
614
614
_pylab_helpers .Gcf .destroy (manager .num )
615
615
else :
616
- error_msg ('Unrecognized argument type to close' )
616
+ error_msg ('Unrecognized argument type %s to close' % type ( arg ) )
617
617
else :
618
618
error_msg ('close takes 0 or 1 arguments' )
619
619
@@ -757,6 +757,15 @@ def figlegend(handles, labels, loc, **kwargs):
757
757
l = gcf ().legend (handles , labels , loc , ** kwargs )
758
758
draw_if_interactive ()
759
759
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__
760
769
761
770
762
771
def 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
767
776
frameon = True ,
768
777
):
769
778
"""
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
+
771
781
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.
772
785
773
- Create a new figure and return a handle to it
774
786
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
777
790
778
791
figure(1)
779
792
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
787
800
788
801
rcParams gives the default values from the .matplotlibrc file
789
802
@@ -1019,28 +1032,6 @@ def save(fname, X, fmt='%1.4f'):
1019
1032
if origShape is not None :
1020
1033
X .shape = origShape
1021
1034
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 )
1044
1035
1045
1036
class _ObjectInspector :
1046
1037
0 commit comments