Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4b4314

Browse files
committed
added autoscale_on property
svn path=/trunk/matplotlib/; revision=1430
1 parent 1fff01d commit f4b4314

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

.matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ tk.pythoninspect : False # tk sets PYTHONINSEPCT
186186
ps.papersize : letter # executive, letter, legal, ledger, A0-A10, B0-B6, C0-C6
187187
ps.useafm : False # use of afm fonts -- breaks mathtext but results in small files
188188
ps.usedistiller : False # Experimental: use ghostscript to distill ps output - may yield smaller files
189-
ps.distiller.res : 600 # dpi
189+
ps.distiller.res : 6000 # dpi
190190

191191
# Set the verbose flags. This controls how much information
192192
# matplotlib gives you at runtime and where it goes. Ther verbosity

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
New entries should be added at the top
22

3+
2005-06-06 Added autoscale_on prop to axes
4+
5+
2005-06-06 Added Nick's picker "among" patch - JDH
6+
37
2005-06-05 Fixed a TeX/LaTeX font discrepency in backend_ps. - DSD
48

59
2005-06-05 Added a ps.distill option in rc settings. If True, postscript

examples/tex_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
fontsize=16, color='r')
3030
grid(True)
3131
savefig('tex_demo.eps')
32+
savefig('jdh.ps')
3233

3334
show()

lib/matplotlib/axes.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)