Skip to content

Commit c154f24

Browse files
committed
added axes position hist patch
svn path=/trunk/matplotlib/; revision=1749
1 parent 757fb84 commit c154f24

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

CHANGELOG

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-09-13 Added Mark's axes positions history patch #1286915
4+
35
2005-09-09 Added support for auto canvas resizing with
46
fig.set_figsize_inches(9,5,forward=True) # inches
57
OR

TODO

+5-1
Original file line numberDiff line numberDiff line change
@@ -722,4 +722,8 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c
722722

723723
-- tex system call problem
724724

725-
-- tex rendering looks fuzzy (dvipng version or flag problem)
725+
-- tex rendering looks fuzzy (dvipng version or flag problem)
726+
727+
-- Martin's zoomhist bug
728+
729+
-- restore robert leftwich's tutorial link to FAQ

lib/matplotlib/__init__.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,32 @@ def ge(self, level):
275275

276276
verbose=Verbose('silent')
277277

278-
279278
def _get_home():
279+
"""Find user's home directory if possible.
280+
Otherwise raise error.
281+
282+
:see: http://mail.python.org/pipermail/python-list/2005-February/263921.html
283+
"""
284+
path=''
285+
try:
286+
path=os.path.expanduser("~")
287+
except:
288+
pass
289+
if not os.path.isdir(path):
290+
for evar in ('HOME', 'USERPROFILE', 'TMP'):
291+
try:
292+
path = os.environ[evar]
293+
if os.path.isdir(path):
294+
break
295+
except: pass
296+
if path:
297+
return path
298+
else:
299+
raise RuntimeError('please define environment variable $HOME')
300+
301+
302+
303+
def _old_get_home(): #ignore me
280304
"""Return the closest possible equivalent to a 'home' directory.
281305
282306
We first try $HOME. Absent that, on NT it's USERPROFILE if

lib/matplotlib/backend_bases.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ def __init__(self, canvas):
970970

971971
# a dict from axes index to a list of view limits
972972
self._views = Stack()
973+
self._positions = Stack() # stack of subplot positions
973974
self._xypress = None # the location and axis info at the time of the press
974975
self._idPress = None
975976
self._idRelease = None
@@ -989,6 +990,7 @@ def set_message(self, s):
989990
def back(self, *args):
990991
'move back up the view lim stack'
991992
self._views.back()
993+
self._positions.back()
992994
self.set_history_buttons()
993995
self._update_view()
994996

@@ -1002,12 +1004,14 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
10021004
def forward(self, *args):
10031005
'move forward in the view lim stack'
10041006
self._views.forward()
1007+
self._positions.forward()
10051008
self.set_history_buttons()
10061009
self._update_view()
10071010

10081011
def home(self, *args):
10091012
'restore the original view'
10101013
self._views.home()
1014+
self._positions.home()
10111015
self.set_history_buttons()
10121016
self._update_view()
10131017

@@ -1150,13 +1154,15 @@ def press_zoom(self, event):
11501154
self.press(event)
11511155

11521156
def push_current(self):
1153-
'push the current view limits onto the stack'
1154-
lims = []
1157+
'push the current view limits and position onto the stack'
1158+
lims = []; pos = []
11551159
for a in self.canvas.figure.get_axes():
11561160
xmin, xmax = a.get_xlim()
11571161
ymin, ymax = a.get_ylim()
11581162
lims.append( (xmin, xmax, ymin, ymax) )
1163+
pos.append( tuple( a.get_position() ) )
11591164
self._views.push(lims)
1165+
self._positions.push(pos)
11601166
self.set_history_buttons()
11611167

11621168

@@ -1353,14 +1359,17 @@ def draw(self):
13531359

13541360

13551361
def _update_view(self):
1356-
'update the viewlim from the view stack for each axes'
1362+
'update the viewlim and position from the view and position stack for each axes'
13571363

13581364
lims = self._views()
13591365
if lims is None: return
1366+
pos = self._positions()
1367+
if pos is None: return
13601368
for i, a in enumerate(self.canvas.figure.get_axes()):
13611369
xmin, xmax, ymin, ymax = lims[i]
13621370
a.set_xlim((xmin, xmax))
13631371
a.set_ylim((ymin, ymax))
1372+
a.set_position( pos[i] )
13641373

13651374
self.draw()
13661375

@@ -1379,6 +1388,7 @@ def set_cursor(self, cursor):
13791388
def update(self):
13801389
'reset the axes stack'
13811390
self._views.clear()
1391+
self._positions.clear()
13821392
self.set_history_buttons()
13831393

13841394
def zoom(self, *args):

0 commit comments

Comments
 (0)