@@ -655,6 +655,8 @@ def cla(self):
655655
656656 self .images = []
657657
658+ self ._autoscaleon = True
659+
658660 self .grid (self ._gridOn )
659661 self .title = Text (
660662 x = 0.5 , y = 1.02 , text = '' ,
@@ -761,6 +763,7 @@ def autoscale_view(self):
761763 'autoscale the view limits using the data limits'
762764 # if image data only just use the datalim
763765
766+ if not self ._autoscaleon : return
764767 if (len (self .images )> 0 and
765768 len (self .lines )== 0 and
766769 len (self .patches )== 0 ):
@@ -1622,6 +1625,18 @@ def get_yticks(self):
16221625 'Return the y ticks as a list of locations'
16231626 return self .yaxis .get_ticklocs ()
16241627
1628+ def get_frame_on (self ):
1629+ """
1630+ Get whether the axes rectangle patch is drawn
1631+ """
1632+ return self ._frameon
1633+
1634+ def get_autoscale_on (self ):
1635+ """
1636+ Get whether autoscaling is applied on plot commands
1637+ """
1638+ return self ._autoscaleon
1639+
16251640 def grid (self , b = None ):
16261641 """
16271642 Set the axes grids on or off; b is a boolean
@@ -1682,6 +1697,14 @@ def set_frame_on(self, b):
16821697 """
16831698 self ._frameon = b
16841699
1700+ def set_autoscale_on (self , b ):
1701+ """
1702+ Set whether the axes rectangle patch is drawn
1703+
1704+ ACCEPTS: True|False
1705+ """
1706+ self ._autoscaleon = b
1707+
16851708 def imshow (self , X ,
16861709 cmap = None ,
16871710 norm = None ,
@@ -3547,13 +3570,20 @@ def disconnect(self, cid):
35473570 self ._connected [key ].remove (item )
35483571 return
35493572
3550- def pick (self , x , y , trans = None ):
3573+ def pick (self , x , y , trans = None , among = None ):
35513574 """
35523575 Return the artist under point that is closest to the x, y. if trans
35533576 is None, x, and y are in window coords, 0,0 = lower left. Otherwise,
35543577 trans is a matplotlib transform that specifies the coordinate system
35553578 of x, y.
3556-
3579+
3580+ The selection of artists from amongst which the pick function
3581+ finds an artist can be narrowed using the optional keyword
3582+ argument among. If provided, this should be either a sequence
3583+ of permitted artists or a function taking an artist as its
3584+ argument and returning a true value if and only if that artist
3585+ can be selected.
3586+
35573587 Note this algorithm calculates distance to the vertices of the
35583588 polygon, so if you want to pick a patch, click on the edge!
35593589 """
@@ -3591,6 +3621,11 @@ def dist(a):
35913621 return dist_x_y (xywin , asarray (xt ), asarray (yt ))
35923622
35933623 artists = self .lines + self .patches + self .texts
3624+ if callable (among ):
3625+ artists = filter (test , artists )
3626+ elif iterable (among ):
3627+ amongd = dict ([(k ,1 ) for k in among ])
3628+ artists = [a for a in artists if a in amongd ]
35943629 if not len (artists ): return None
35953630 ds = [ (dist (a ),a ) for a in artists ]
35963631 ds .sort ()
0 commit comments