Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 46906da

Browse filesBrowse files
committed
some aspect ratio fixes
svn path=/trunk/matplotlib/; revision=869
1 parent 18204b0 commit 46906da
Copy full SHA for 46906da

File tree

Expand file treeCollapse file tree

3 files changed

+17
-46
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-46
lines changed

‎lib/matplotlib/backends/backend_tkagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_tkagg.py
+2-35Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def show(self):
266266
def destroy(*args):
267267
self.window = None
268268
Gcf.destroy(self._num)
269+
269270
if not self._shown: self.window.bind("<Destroy>", destroy)
270271

271272
_focus = windowing.FocusManager()
@@ -276,47 +277,13 @@ def destroy(*args):
276277
else: self.canvas.draw()
277278
self._shown = True
278279

279-
def _show(self):
280-
"""
281-
# this function segfaults on an interactive session in pylab
282-
283-
1 >>> plot([1,2,3])
284-
Out[1]: [<matplotlib.lines.Line2D instance at 0x418ed62c>]
285-
CLOSE WINDOW
286-
2 >>> plot([1,2,3])
287-
Segmentation fault
288-
289-
I now realize that any call to self.window.bind("<Destroy>", destroy)
290-
causes the PyEval_RestoreThread: NULL state bug if the mainloop is not started. Due to the placement of
291-
292-
if not self._shown: self.window.bind("<Destroy>", destroy)
293-
294-
after the setting of
295-
296-
self._shown = True
297-
298-
it is never called
299-
300-
"""
301-
_focus = windowing.FocusManager()
302-
if not self._shown:
303-
self.window.deiconify()
304-
# anim.py requires this
305-
if not sys.platform.startswith('linux') :
306-
self.window.update()
307-
else: self.canvas.draw()
308-
self._shown = True
309-
def destroy(*args):
310-
self.window = None
311-
Gcf.destroy(self._num)
312-
if not self._shown: self.window.bind("<Destroy>", destroy)
313-
314280

315281
def destroy(self, *args):
316282
if Gcf.get_num_fig_managers()==0 and not matplotlib.is_interactive():
317283
if self.window is not None:
318284
self.window.quit()
319285
if self.window is not None:
286+
#print 'calling window destroy'
320287
self.window.destroy()
321288
self.window = None
322289

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+14-10Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def changed(self):
106106
self._imcache = None
107107
cm.ScalarMappable.changed(self)
108108

109-
def make_image(self, flipy):
109+
def make_image(self, flipy):
110+
self._imcache = None
110111
if self._A is not None:
111112
if self._imcache is None:
112113
x = self.to_rgba(self._A, self._alpha)
@@ -158,10 +159,12 @@ def make_image(self, flipy):
158159
rx = widthDisplay / numcols
159160
ry = heightDisplay / numrows
160161

162+
161163
if im.get_aspect()==_image.ASPECT_PRESERVE:
162164
if ry < rx: rx = ry
163165
# todo: center the image in viewport
164166
im.apply_scaling(rx, rx)
167+
165168
else:
166169
im.apply_scaling(rx, ry)
167170

@@ -258,21 +261,22 @@ def set_interpolation(self, s):
258261
if not self._interpd.has_key(s):
259262
raise ValueError('Illegal interpolation string')
260263
self._interpolation = s
261-
262-
263-
264-
265264

266265
def get_extent(self):
267266
'get the image extent: xmin, xmax, ymin, ymax'
268267
if self._extent is not None:
269268
return self._extent
270-
else:
269+
else:
271270
numrows, numcols = self.get_size()
272-
width, height = numcols, numrows
273-
return 0, width, 0, height
274-
275-
271+
iwidth, iheight = numcols, numrows
272+
#return 0, width, 0, height
273+
tmp, tmp, dwidth, dheight = self.axes.bbox.get_bounds()
274+
sx = dwidth / iwidth
275+
sy = dheight / iheight
276+
277+
if self.get_aspect()=='preserve' and sy<sx: sx = sy
278+
return 0, 1.0/sx*dwidth, 0, 1.0/sy*dheight
279+
276280
class FigureImage(Artist, cm.ScalarMappable):
277281
def __init__(self, fig,
278282
cmap = None,

‎unit/memleak_hawaii3.py

Copy file name to clipboardExpand all lines: unit/memleak_hawaii3.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import matplotlib
55
matplotlib.interactive(True)
66
#matplotlib.use('Cairo')
7-
matplotlib.use('WXAgg')
7+
matplotlib.use('TkAgg')
88
from pylab import *
99

1010

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.