1111import numerix .ma as ma
1212
1313import matplotlib .mlab
14+ import matplotlib .agg as agg
1415import artist
1516from artist import Artist , setp
1617from axis import XAxis , YAxis
@@ -883,16 +884,8 @@ def get_child_artists(self):
883884 """
884885 Return a list of artists the axes contains. Deprecated
885886 """
886- artists = [self .title , self .axesPatch , self .xaxis , self .yaxis ]
887- artists .extend (self .lines )
888- artists .extend (self .patches )
889- artists .extend (self .texts )
890- artists .extend (self .collections )
891- artists .extend (self .images )
892- if self .legend_ is not None :
893- artists .append (self .legend_ )
894- return silent_list ('Artist' , artists )
895-
887+ raise DeprecationWarning ('Use get_children instead' )
888+
896889 def get_frame (self ):
897890 'Return the axes Rectangle frame'
898891 return self .axesPatch
@@ -4967,7 +4960,7 @@ def _set_lim_and_transforms(self):
49674960 Point ( Value (1 / 4. * math .pi ), Value (math .sqrt (2 ))))
49684961
49694962 self .transData = NonseparableTransformation (self .viewLim , self .bbox ,
4970- FuncXY (POLAR ))
4963+ FuncXY (POLAR ))
49714964 self .transAxes = get_bbox_transform (unit_bbox (), self .bbox )
49724965
49734966
@@ -5013,6 +5006,7 @@ def cla(self):
50135006 edgecolor = rcParams ['axes.edgecolor' ],
50145007 )
50155008
5009+
50165010 self .axesPatch .set_figure (self .figure )
50175011 self .axesPatch .set_transform (self .transData )
50185012 self .axesPatch .set_linewidth (rcParams ['axes.linewidth' ])
@@ -5035,16 +5029,35 @@ def cla(self):
50355029 self .set_thetagrids (angles )
50365030 self .set_rgrids (radii )
50375031
5032+ def get_children (self ):
5033+ 'return a list of child artists'
5034+ children = []
5035+ children .extend (self .rgridlines )
5036+ children .extend (self .rgridlabels )
5037+ children .extend (self .thetagridlines )
5038+ children .extend (self .thetagridlabels )
5039+ children .extend (self .lines )
5040+ children .extend (self .patches )
5041+ children .extend (self .texts )
5042+ children .extend (self .artists )
5043+ children .extend (self .images )
5044+ #if self.legend_ is not None:
5045+ # children.append(self.legend_)
5046+ children .extend (self .collections )
5047+ children .append (self .title )
5048+ children .append (self .axesPatch )
5049+ return children
5050+
5051+
5052+ def set_rmax (self , rmax ):
5053+ self .rintv .set_bounds (0 , rmax )
5054+ self .regrid (rmax )
5055+
50385056 def grid (self , b ):
50395057 'Set the axes grids on or off; b is a boolean'
50405058 self ._gridOn = b
50415059
5042- def autoscale_view (self , scalex = True , scaley = True ):
5043- 'set the view limits to include all the data in the axes'
5044- self .rintd .set_bounds (0 , self .get_rmax ())
5045- rmin , rmax = self .rlocator .autoscale ()
5046- self .rintv .set_bounds (rmin , rmax )
5047-
5060+ def regrid (self , rmax ):
50485061 self .axesPatch .xy = zip (self .thetas , rmax * ones (self .RESOLUTION ))
50495062 val = rmax * math .sqrt (2 )
50505063 self .viewLim .intervaly ().set_bounds (val , val )
@@ -5058,7 +5071,14 @@ def autoscale_view(self, scalex=True, scaley=True):
50585071 r = linspace (0 , rmax , self .RESOLUTION )
50595072 for l in self .thetagridlines :
50605073 l .set_ydata (r )
5061-
5074+
5075+ def autoscale_view (self , scalex = True , scaley = True ):
5076+ 'set the view limits to include all the data in the axes'
5077+ self .rintd .set_bounds (0 , self .get_rmax ())
5078+ rmin , rmax = self .rlocator .autoscale ()
5079+ self .rintv .set_bounds (rmin , rmax )
5080+ self .regrid (rmax )
5081+
50625082 def set_rgrids (self , radii , labels = None , angle = 22.5 , ** kwargs ):
50635083 """
50645084 set the radial locations and labels of the r grids
@@ -5182,14 +5202,38 @@ def draw(self, renderer):
51825202 self .apply_aspect (1 )
51835203 self .transData .freeze () # eval the lazy objects
51845204 self .transAxes .freeze () # eval the lazy objects
5205+
5206+ tverts = self .transData .seq_xy_tups (self .axesPatch .get_verts ())
5207+
5208+ def make_clippath ():
5209+ clippath = agg .path_storage ()
5210+ for i , xy in enumerate (tverts ):
5211+ if i == 0 : clippath .move_to (* xy )
5212+ else : clippath .line_to (* xy )
5213+ clippath .close_polygon ()
5214+ return clippath
5215+
5216+ clippath = agg .path_storage ()
5217+ for i , xy in enumerate (tverts ):
5218+ if i == 0 : clippath .move_to (* xy )
5219+ else : clippath .line_to (* xy )
5220+ clippath .close_polygon ()
5221+
51855222 #self._update_axes()
51865223 if self .axison :
51875224 if self ._frameon : self .axesPatch .draw (renderer )
51885225
51895226 if self ._gridOn :
51905227 for l in self .rgridlines + self .thetagridlines :
5228+ #l.set_clip_path(make_clippath())
5229+ #l.set_clip_path(clippath)
51915230 l .draw (renderer )
51925231
5232+ for line in self .lines :
5233+ #line.set_clip_path(make_clippath())
5234+ #line.set_clip_path(clippath)
5235+ pass
5236+
51935237 for t in self .thetagridlabels + self .rgridlabels :
51945238 t .draw (renderer )
51955239
@@ -5230,26 +5274,35 @@ def set_ylabel(self, ylabel, fontdict=None, **kwargs):
52305274 raise NotImplementedError ('ylabel not defined for polar axes (yet)' )
52315275
52325276
5233- def set_xlim (self , v , emit = True ):
5277+ def set_xlim (self , xmin = None , xmax = None , emit = True ):
52345278 """
5235- SET_XLIM(v, emit=True)
5236-
5237- A do nothing impl until we can figure out how to handle interaction
5279+ set the xlimits
52385280 ACCEPTS: len(2) sequence of floats
52395281 """
5240- #warnings.warn('Navigation set_ylim not implemented for polar')
5241- self .viewLim .intervalx ().set_bounds (* v )
5282+ if xmax is None and iterable (xmin ):
5283+ xmin ,xmax = xmin
5284+
5285+ old_xmin ,old_xmax = self .get_xlim ()
5286+ if xmin is None : xmin = old_xmin
5287+ if xmax is None : xmax = old_xmax
5288+
5289+ self .viewLim .intervalx ().set_bounds (xmin , xmax )
52425290 if emit : self ._send_xlim_event ()
52435291
52445292
5245- def set_ylim (self , v , emit = True ):
5293+ def set_ylim (self , ymin = None , ymax = None , emit = True ):
52465294 """
5247- SET_YLIM(v, emit=True)
5248-
5295+ set the ylimits
52495296 ACCEPTS: len(2) sequence of floats
52505297 """
5251- #warnings.warn('Navigation set_xlim not implemented for polar')
5252- self .viewLim .intervaly ().set_bounds (* v )
5298+ if ymax is None and iterable (ymin ):
5299+ ymin ,ymax = ymin
5300+
5301+ old_ymin ,old_ymax = self .get_ylim ()
5302+ if ymin is None : ymin = old_ymin
5303+ if ymax is None : ymax = old_ymax
5304+
5305+ self .viewLim .intervaly ().set_bounds (ymin , ymax )
52535306 if emit : self ._send_ylim_event ()
52545307
52555308 def get_xscale (self ):
0 commit comments