@@ -117,10 +117,6 @@ def __init__(self,
117117 subplotpars is a SubplotParams instance, defaults to rc
118118 """
119119 Artist .__init__ (self )
120- #self.set_figure(self)
121- self ._axstack = Stack () # maintain the current axes
122- self ._axobservers = []
123- self ._seen = {} # axes args we've seen
124120
125121 if figsize is None : figsize = rcParams ['figure.figsize' ]
126122 if dpi is None : dpi = rcParams ['figure.dpi' ]
@@ -156,6 +152,7 @@ def __init__(self,
156152
157153 self .subplotpars = subplotpars
158154
155+ self ._axstack = Stack () # maintain the current axes
159156 self .clf ()
160157
161158 self ._cachedRenderer = None
@@ -170,11 +167,11 @@ def get_children(self):
170167 children .extend (self .images )
171168 children .extend (self .legends )
172169 return children
173-
170+
174171 def pick (self , mouseevent ):
175172 for a in self .get_children ():
176173 a .pick (mouseevent )
177-
174+
178175 def get_window_extent (self , * args , ** kwargs ):
179176 'get the figure bounding box in display space; kwargs are void'
180177 return self .bbox
@@ -525,6 +522,7 @@ def clf(self):
525522 self .texts = []
526523 self .images = []
527524 self .legends = []
525+ self ._axobservers = []
528526
529527 def clear (self ):
530528 """
@@ -727,15 +725,6 @@ def savefig(self, *args, **kwargs):
727725 self .canvas .print_figure (* args , ** kwargs )
728726
729727 def colorbar (self , mappable , cax = None , ** kw ):
730- # Temporary compatibility code:
731- old = ('tickfmt' , 'cspacing' , 'clabels' , 'edgewidth' , 'edgecolor' )
732- oldkw = [k for k in old if kw .has_key (k )]
733- if oldkw :
734- msg = 'Old colorbar kwargs (%s) found; using colorbar_classic.' % (',' .join (oldkw ),)
735- warnings .warn (msg , DeprecationWarning )
736- self .colorbar_classic (mappable , cax , ** kw )
737- return cax
738- # End of compatibility code block.
739728 orientation = kw .get ('orientation' , 'vertical' )
740729 ax = self .gca ()
741730 if cax is None :
@@ -751,170 +740,6 @@ def colorbar(self, mappable, cax=None, **kw):
751740 Documentation for the pylab thin wrapper: %s
752741 ''' % cbar .colorbar_doc
753742
754- def colorbar_classic (self , mappable , cax = None ,
755- orientation = 'vertical' , tickfmt = '%1.1f' ,
756- cspacing = 'proportional' ,
757- clabels = None , drawedges = False , edgewidth = 0.5 ,
758- edgecolor = 'k' ):
759- """
760- Create a colorbar for mappable image
761-
762- mappable is the cm.ScalarMappable instance that you want the
763- colorbar to apply to, e.g. an Image as returned by imshow or a
764- PatchCollection as returned by scatter or pcolor.
765-
766- tickfmt is a format string to format the colorbar ticks
767-
768- cax is a colorbar axes instance in which the colorbar will be
769- placed. If None, as default axesd will be created resizing the
770- current aqxes to make room for it. If not None, the supplied axes
771- will be used and the other axes positions will be unchanged.
772-
773- orientation is the colorbar orientation: one of 'vertical' | 'horizontal'
774-
775- cspacing controls how colors are distributed on the colorbar.
776- if cspacing == 'linear', each color occupies an equal area
777- on the colorbar, regardless of the contour spacing.
778- if cspacing == 'proportional' (Default), the area each color
779- occupies on the the colorbar is proportional to the contour interval.
780- Only relevant for a Contour image.
781-
782- clabels can be a sequence containing the
783- contour levels to be labelled on the colorbar, or None (Default).
784- If clabels is None, labels for all contour intervals are
785- displayed. Only relevant for a Contour image.
786-
787- if drawedges == True, lines are drawn at the edges between
788- each color on the colorbar. Default False.
789-
790- edgecolor is the line color delimiting the edges of the colors
791- on the colorbar (if drawedges == True). Default black ('k')
792-
793- edgewidth is the width of the lines delimiting the edges of
794- the colors on the colorbar (if drawedges == True). Default 0.5
795-
796- return value is the colorbar axes instance
797- """
798-
799- if orientation not in ('horizontal' , 'vertical' ):
800- raise ValueError ('Orientation must be horizontal or vertical' )
801-
802- if isinstance (mappable , FigureImage ) and cax is None :
803- raise TypeError ('Colorbars for figure images currently not supported unless you provide a colorbar axes in cax' )
804-
805-
806- ax = self .gca ()
807-
808- cmap = mappable .cmap
809-
810- if cax is None :
811- l ,b ,w ,h = ax .get_position ()
812- if orientation == 'vertical' :
813- neww = 0.8 * w
814- ax .set_position ((l ,b ,neww ,h ), 'both' )
815- cax = self .add_axes ([l + 0.9 * w , b , 0.1 * w , h ])
816- else :
817- newh = 0.8 * h
818- ax .set_position ((l ,b + 0.2 * h ,w ,newh ), 'both' )
819- cax = self .add_axes ([l , b , w , 0.1 * h ])
820-
821- else :
822- if not isinstance (cax , Axes ):
823- raise TypeError ('Expected an Axes instance for cax' )
824-
825- norm = mappable .norm
826- if norm .vmin is None or norm .vmax is None :
827- mappable .autoscale ()
828- cmin = norm .vmin
829- cmax = norm .vmax
830- if isinstance (mappable , ContourSet ):
831- # mappable image is from contour or contourf
832- clevs = mappable .levels
833- clevs = minimum (clevs , cmax )
834- clevs = maximum (clevs , cmin )
835- isContourSet = True
836- elif isinstance (mappable , ScalarMappable ):
837- # from imshow or pcolor.
838- isContourSet = False
839- clevs = linspace (cmin , cmax , cmap .N + 1 ) # boundaries, hence N+1
840- else :
841- raise TypeError ("don't know how to handle type %s" % type (mappable ))
842-
843- N = len (clevs )
844- C = array ([clevs , clevs ])
845- if cspacing == 'linear' :
846- X , Y = meshgrid (clevs , [0 , 1 ])
847- elif cspacing == 'proportional' :
848- X , Y = meshgrid (linspace (cmin , cmax , N ), [0 , 1 ])
849- else :
850- raise ValueError ("cspacing must be 'linear' or 'proportional'" )
851-
852- if orientation == 'vertical' :
853- args = (transpose (Y ), transpose (C ), transpose (X ), clevs )
854- else :
855- args = (C , Y , X , clevs )
856- #If colors were listed in the original mappable, then
857- # let contour handle them the same way.
858- colors = getattr (mappable , 'colors' , None )
859- if colors is not None :
860- kw = {'colors' : colors }
861- else :
862- kw = {'cmap' :cmap , 'norm' :norm }
863- if isContourSet and not mappable .filled :
864- CS = cax .contour (* args , ** kw )
865- colls = mappable .collections
866- for ii in range (len (colls )):
867- CS .collections [ii ].set_linewidth (colls [ii ].get_linewidth ())
868- else :
869- kw ['antialiased' ] = False
870- CS = cax .contourf (* args , ** kw )
871- if drawedges :
872- for col in CS .collections :
873- col .set_edgecolor (edgecolor )
874- col .set_linewidth (edgewidth )
875-
876- mappable .add_observer (CS )
877- mappable .set_colorbar (CS , cax )
878-
879-
880- if isContourSet :
881- if cspacing == 'linear' :
882- ticks = linspace (cmin , cmax , N )
883- else :
884- ticks = clevs
885- if cmin == mappable .levels [0 ]:
886- ticklevs = clevs
887- else : # We are not showing the full ends of the range.
888- ticks = ticks [1 :- 1 ]
889- ticklevs = clevs [1 :- 1 ]
890- labs = [tickfmt % lev for lev in ticklevs ]
891- if clabels is not None :
892- for i , lev in enumerate (ticklevs ):
893- if lev not in clabels :
894- labs [i ] = ''
895-
896-
897- if orientation == 'vertical' :
898- cax .set_xticks ([])
899- cax .yaxis .tick_right ()
900- cax .yaxis .set_label_position ('right' )
901- if isContourSet :
902- cax .set_yticks (ticks )
903- cax .set_yticklabels (labs )
904- else :
905- cax .yaxis .set_major_formatter (FormatStrFormatter (tickfmt ))
906- else :
907- cax .set_yticks ([])
908- if isContourSet :
909- cax .set_xticks (ticks )
910- cax .set_xticklabels (labs )
911- else :
912- cax .xaxis .set_major_formatter (FormatStrFormatter (tickfmt ))
913-
914- self .sca (ax )
915- return cax
916-
917-
918743 def subplots_adjust (self , * args , ** kwargs ):
919744 """
920745 subplots_adjust(self, left=None, bottom=None, right=None, top=None,
0 commit comments