SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(3)
2
(2)
3
(5)
4
(1)
5
6
7
(6)
8
(3)
9
(7)
10
(6)
11
(14)
12
(6)
13
(10)
14
(6)
15
16
17
(15)
18
(6)
19
(1)
20
(4)
21
(8)
22
(9)
23
(12)
24
(35)
25
(21)
26
(14)
27
(11)
28
(9)
29
(11)
30
(6)
31
(9)


Showing 5 results of 5

From: <md...@us...> - 2008年07月03日 16:09:29
Revision: 5711
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5711&view=rev
Author: mdboom
Date: 2008年07月03日 09:08:52 -0700 (2008年7月03日)
Log Message:
-----------
O(n) implementation of Grouper.__iter__
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 14:30:41 UTC (rev 5710)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 16:08:52 UTC (rev 5711)
@@ -1030,7 +1030,7 @@
 >>> g.join('a', 'b')
 >>> g.join('b', 'c')
 >>> g.join('d', 'e')
- >>> list(g.get())
+ >>> list(g)
 [['a', 'b', 'c'], ['d', 'e']]
 >>> g.joined('a', 'b')
 True
@@ -1079,14 +1079,25 @@
 
 def __iter__(self):
 """
- Returns an iterator yielding each of the disjoint sets as a list.
+ Iterate over each of the disjoint sets as a list.
+
+ The iterator is invalid if interleaved with calls to join().
 """
- seen = set()
- for elem, group in self._mapping.iteritems():
- if elem not in seen:
+ class Token: pass
+ token = Token()
+
+ # Mark each group as we come across if by appending a token,
+ # and don't yield it twice
+ for group in self._mapping.itervalues():
+ if not group[-1] is token:
 yield group
- seen.update(group)
+ group.append(token)
 
+ # Cleanup the tokens
+ for group in self._mapping.itervalues():
+ if group[-1] is token:
+ del group[-1]
+
 def get_siblings(self, a):
 """
 Returns all of the items joined with *a*, including itself.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5710
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5710&view=rev
Author: jdh2358
Date: 2008年07月03日 07:30:41 -0700 (2008年7月03日)
Log Message:
-----------
added findobj
Modified Paths:
--------------
 trunk/matplotlib/examples/pylab_examples/findobj_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/findobj_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/findobj_demo.py	2008年07月03日 14:30:13 UTC (rev 5709)
+++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py	2008年07月03日 14:30:41 UTC (rev 5710)
@@ -1,3 +1,6 @@
+"""
+Recursuvely find all objects that match some criteria
+"""
 import numpy as np
 import matplotlib.pyplot as plt
 import matplotlib.text as text
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月03日 14:30:16
Revision: 5709
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5709&view=rev
Author: jdh2358
Date: 2008年07月03日 07:30:13 -0700 (2008年7月03日)
Log Message:
-----------
added findobj
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/artist.py
 trunk/matplotlib/lib/matplotlib/cbook.py
 trunk/matplotlib/lib/matplotlib/legend.py
 trunk/matplotlib/lib/matplotlib/pylab.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Added Paths:
-----------
 trunk/matplotlib/examples/pylab_examples/findobj_demo.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/CHANGELOG	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -1,3 +1,6 @@
+2007年07月03日 Implemented findobj method for artist and pyplot - see
+ examples/pylab_examples/findobj_demo.py - JDH
+
 2008年06月30日 Another attempt to fix TextWithDash - DSD
 
 2008年06月30日 Removed Qt4 NavigationToolbar2.destroy -- it appears to 
Added: trunk/matplotlib/examples/pylab_examples/findobj_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/findobj_demo.py	 (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -0,0 +1,34 @@
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.text as text
+
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+plt.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+plt.ylim([-1,20])
+plt.grid(False)
+plt.xlabel('Model complexity --->')
+plt.ylabel('Message length --->')
+plt.title('Minimum Message Length')
+
+# match on arbitrary function
+def myfunc(x):
+ return hasattr(x, 'set_color')
+
+for o in fig.findobj(myfunc):
+ o.set_color('blue')
+
+# match on class instances
+for o in fig.findobj(text.Text):
+ o.set_fontstyle('italic')
+
+
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/artist.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -508,7 +508,47 @@
 ret.extend( [func(v)] )
 return ret
 
+ def findobj(self, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in self
 
+ *match* can be
+
+ - None: return all objects contained in artist (including artist)
+
+ - function with signature ``boolean = match(artist)`` used to filter matches
+
+ - class instance: eg Line2D. Only return artists of class type
+ """
+
+ if match is None: # always return True
+ def matchfunc(x): return True
+ elif cbook.issubclass_safe(match, Artist):
+ def matchfunc(x):
+ return isinstance(x, match)
+ elif callable(match):
+ matchfunc = match
+ else:
+ raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
+
+
+ artists = []
+ if hasattr(self, 'get_children'):
+ for c in self.get_children():
+ if matchfunc(c):
+ artists.append(c)
+ artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
+ else:
+ if matchfunc(self):
+ artists.append(self)
+ return artists
+
+
+
+
+
+
 class ArtistInspector:
 """
 A helper class to inspect an :class:`~matplotlib.artist.Artist`
@@ -690,6 +730,48 @@
 return lines
 
 
+
+ def findobj(self, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in self
+
+ if *match* is not None, it can be
+
+ - function with signature ``boolean = match(artist)``
+
+ - class instance: eg Line2D
+
+ used to filter matches
+ """
+
+ if match is None: # always return True
+ def matchfunc(x): return True
+ elif issubclass(match, Artist):
+ def matchfunc(x):
+ return isinstance(x, match)
+ elif callable(match):
+ matchfunc = func
+ else:
+ raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
+
+
+ artists = []
+ if hasattr(self, 'get_children'):
+ for c in self.get_children():
+ if matchfunc(c):
+ artists.append(c)
+ artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
+ else:
+ if matchfunc(self):
+ artists.append(self)
+ return artists
+
+
+
+
+
+
 def getp(o, property=None):
 """
 Return the value of handle property. property is an optional string
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -886,7 +886,14 @@
 raise ValueError(_safezip_msg % (Nx, i+1, len(arg)))
 return zip(*args)
 
+def issubclass_safe(x, klass):
+ 'return issubclass(x, klass) and return False on a TypeError'
 
+ try:
+ return issubclass(x, klass)
+ except TypeError:
+ return False
+
 class MemoryMonitor:
 def __init__(self, nmax=20000):
 self._nmax = nmax
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/legend.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -363,6 +363,12 @@
 'b is a boolean. Set draw frame to b'
 self._drawFrame = b
 
+ def get_children(self):
+ children = []
+ children.extend(self.legendHandles)
+ children.extend(self.texts)
+ return children
+
 def get_frame(self):
 'return the Rectangle instance used to frame the legend'
 return self.legendPatch
Modified: trunk/matplotlib/lib/matplotlib/pylab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pylab.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/pylab.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -38,6 +38,7 @@
 figtext - add text in figure coords
 figure - create or change active figure
 fill - make filled polygons
+ findobj - recursively find all objects matching some criteria
 gca - return the current axes
 gcf - return the current figure
 gci - get the current image, or None
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -38,6 +38,29 @@
 from matplotlib.backends import pylab_setup
 new_figure_manager, draw_if_interactive, show = pylab_setup()
 
+
+
+def findobj(o=None, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in artist instance *p*. if *o* is None, use
+ current figure
+
+ *match* can be
+
+ - None: return all objects contained in artist (including artist)
+
+ - function with signature ``boolean = match(artist)`` used to filter matches
+
+ - class instance: eg Line2D. Only return artists of class type
+
+ """
+
+ if o is None:
+ o = gcf()
+ return o.findobj(match)
+
+
 def switch_backend(newbackend):
 """
 Switch the default backend to newbackend. This feature is
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月03日 13:38:59
Revision: 5708
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5708&view=rev
Author: jdh2358
Date: 2008年07月03日 06:38:52 -0700 (2008年7月03日)
Log Message:
-----------
fixed text picking
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/text.py
Added Paths:
-----------
 trunk/matplotlib/examples/api/line_with_text.py
Added: trunk/matplotlib/examples/api/line_with_text.py
===================================================================
--- trunk/matplotlib/examples/api/line_with_text.py	 (rev 0)
+++ trunk/matplotlib/examples/api/line_with_text.py	2008年07月03日 13:38:52 UTC (rev 5708)
@@ -0,0 +1,65 @@
+"""
+Show how to override basic methods so an artist can contain another
+artist. In this case, the line contains a Text instance to label it.
+"""
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.lines as lines
+import matplotlib.transforms as mtransforms
+import matplotlib.text as mtext
+
+
+class MyLine(lines.Line2D):
+
+ def __init__(self, *args, **kwargs):
+ # we'll update the position when the line data is set
+ self.text = mtext.Text(0, 0, '')
+ lines.Line2D.__init__(self, *args, **kwargs)
+
+ # we can't access the label attr until *after* the line is
+ # inited
+ self.text.set_text(self.get_label())
+
+ def set_figure(self, figure):
+ self.text.set_figure(figure)
+ lines.Line2D.set_figure(self, figure)
+
+ def set_axes(self, axes):
+ self.text.set_axes(axes)
+ lines.Line2D.set_axes(self, axes)
+
+ def set_transform(self, transform):
+ # 2 pixel offset
+ texttrans = transform + mtransforms.Affine2D().translate(2, 2)
+ self.text.set_transform(texttrans)
+ lines.Line2D.set_transform(self, transform)
+
+
+ def set_data(self, x, y):
+ if len(x):
+ self.text.set_position((x[-1], y[-1]))
+
+ lines.Line2D.set_data(self, x, y)
+
+ def draw(self, renderer):
+ # draw my label at the end of the line with 2 pixel offset
+ lines.Line2D.draw(self, renderer)
+ self.text.draw(renderer)
+
+
+
+
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+x, y = np.random.rand(2, 20)
+line = MyLine(x, y, mfc='red', ms=12, label='line label')
+#line.text.set_text('line label')
+line.text.set_color('red')
+line.text.set_fontsize(16)
+
+
+ax.add_line(line)
+
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py	2008年07月03日 13:21:54 UTC (rev 5707)
+++ trunk/matplotlib/lib/matplotlib/text.py	2008年07月03日 13:38:52 UTC (rev 5708)
@@ -135,17 +135,15 @@
 """
 if callable(self._contains): return self._contains(self,mouseevent)
 
- try:
- l,b,w,h = self.get_window_extent().get_bounds()
- except:
- # TODO: why does this error occur
- #print str(self),"error looking at get_window_extent"
- return False,{}
+
+ l,b,w,h = self.get_window_extent().bounds
+
 r = l+w
 t = b+h
 xyverts = (l,b), (l, t), (r, t), (r, b)
 x, y = mouseevent.x, mouseevent.y
 inside = nxutils.pnpoly(x, y, xyverts)
+
 return inside,{}
 
 def _get_xy_display(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月03日 13:22:14
Revision: 5707
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5707&view=rev
Author: jdh2358
Date: 2008年07月03日 06:21:54 -0700 (2008年7月03日)
Log Message:
-----------
axes was not calling artist set_axes method in set artist props
Modified Paths:
--------------
 trunk/matplotlib/examples/widgets/menu.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_backend_agg.h
 trunk/matplotlib/unit/memleak_hawaii3.py
Modified: trunk/matplotlib/examples/widgets/menu.py
===================================================================
--- trunk/matplotlib/examples/widgets/menu.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/examples/widgets/menu.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -1,45 +1,76 @@
 import numpy as np
 import matplotlib
+import matplotlib.colors as colors
 import matplotlib.patches as patches
 import matplotlib.mathtext as mathtext
 import matplotlib.pyplot as plt
 import matplotlib.artist as artist
 import matplotlib.image as image
 
-matplotlib.rc('image', origin='upper')
 
+class ItemProperties:
+ def __init__(self, fontsize=14, labelcolor='black', bgcolor='yellow', alpha=1.0):
+ self.fontsize = fontsize
+ self.labelcolor = labelcolor
+ self.bgcolor = bgcolor
+ self.alpha = alpha
+
+ self.labelcolor_rgb = colors.colorConverter.to_rgb(labelcolor)
+ self.bgcolor_rgb = colors.colorConverter.to_rgb(bgcolor)
+
 class MenuItem(artist.Artist):
 parser = mathtext.MathTextParser("Bitmap")
 padx = 5
 pady =5
- def __init__(self, fig, labelstr):
+ def __init__(self, fig, labelstr, props=None, hoverprops=None, on_select=None):
 artist.Artist.__init__(self)
+
 self.set_figure(fig)
+ self.labelstr = labelstr
 
+ if props is None:
+ props = ItemProperties()
 
- x, self.depth = self.parser.to_rgba(
- labelstr, color='black', fontsize=14, dpi=100)
- xHover, depth = self.parser.to_rgba(
- labelstr, color='white', fontsize=14, dpi=100)
+ if hoverprops is None:
+ hoverprops = ItemProperties()
 
+ self.props = props
+ self.hoverprops = hoverprops
 
+
+ self.on_select = on_select
+
+ x, self.depth = self.parser.to_mask(
+ labelstr, fontsize=props.fontsize, dpi=fig.dpi)
+
+ if props.fontsize!=hoverprops.fontsize:
+ raise NotImplementedError('support for different font sizes not implemented')
+
+
 self.labelwidth = x.shape[1]
 self.labelheight = x.shape[0]
- print 'h', self.labelheight
- self.label = image.FigureImage(fig)
- self.label.set_array(x.astype(float)/255.)
 
- self.labelHover = image.FigureImage(fig)
- self.labelHover.set_array(xHover.astype(float)/255.)
+ self.labelArray = np.zeros((x.shape[0], x.shape[1], 4))
+ self.labelArray[:,:,-1] = x/255.
 
+ self.label = image.FigureImage(fig, origin='upper')
+ self.label.set_array(self.labelArray)
 
-
 # we'll update these later
- self.rect = patches.Rectangle((0,0), 1,1, facecolor='yellow', alpha=0.2)
- self.rectHover = patches.Rectangle((0,0), 1,1, facecolor='blue', alpha=0.2)
+ self.rect = patches.Rectangle((0,0), 1,1)
 
+ self.set_hover_props(False)
 
+ fig.canvas.mpl_connect('button_release_event', self.check_select)
 
+ def check_select(self, event):
+ over, junk = self.rect.contains(event)
+ if not over:
+ return
+
+ if self.on_select is not None:
+ self.on_select(self)
+
 def set_extent(self, x, y, w, h):
 print x, y, w, h
 self.rect.set_x(x)
@@ -47,65 +78,64 @@
 self.rect.set_width(w)
 self.rect.set_height(h)
 
- self.rectHover.set_x(x)
- self.rectHover.set_y(y)
- self.rectHover.set_width(w)
- self.rectHover.set_height(h)
-
 self.label.ox = x+self.padx
 self.label.oy = y-self.depth+self.pady/2.
 
 self.rect._update_patch_transform()
- self.rectHover._update_patch_transform()
- self.labelHover.ox = x+self.padx
- self.labelHover.oy = y-self.depth+self.pady/2.
 self.hover = False
 
- self.activeRect = self.rect
- self.activeLabel = self.label
-
 def draw(self, renderer):
- self.activeRect.draw(renderer)
- self.activeLabel.draw(renderer)
+ self.rect.draw(renderer)
+ self.label.draw(renderer)
 
+ def set_hover_props(self, b):
+ if b:
+ props = self.hoverprops
+ else:
+ props = self.props
+
+ r, g, b = props.labelcolor_rgb
+ self.labelArray[:,:,0] = r
+ self.labelArray[:,:,1] = g
+ self.labelArray[:,:,2] = b
+ self.label.set_array(self.labelArray)
+ self.rect.set(facecolor=props.bgcolor, alpha=props.alpha)
+
 def set_hover(self, event):
 'check the hover status of event and return true if status is changed'
 b,junk = self.rect.contains(event)
- if b:
- self.activeRect = self.rectHover
- self.activeLabel = self.labelHover
- else:
- self.activeRect = self.rect
- self.activeLabel = self.label
 
- h = self.hover
+ changed = (b != self.hover)
+
+ if changed:
+ self.set_hover_props(b)
+
+
 self.hover = b
- return b!=h
+ return changed
 
 class Menu:
 
- def __init__(self, fig, labels):
+ def __init__(self, fig, menuitems):
 self.figure = fig
 fig.suppressComposite = True
- menuitems = []
- self.numitems = len(labels)
- for label in labels:
- menuitems.append(MenuItem(fig, label))
 
 self.menuitems = menuitems
+ self.numitems = len(menuitems)
 
-
 maxw = max([item.labelwidth for item in menuitems])
 maxh = max([item.labelheight for item in menuitems])
 
 
 totalh = self.numitems*maxh + (self.numitems+1)*2*MenuItem.pady
 
+
 x0 = 100
 y0 = 400
 
 width = maxw + 2*MenuItem.padx
 height = maxh+MenuItem.pady
+
 for item in menuitems:
 left = x0
 bottom = y0-maxh-MenuItem.pady
@@ -122,17 +152,27 @@
 def on_move(self, event):
 draw = False
 for item in self.menuitems:
- b = item.set_hover(event)
- draw = b
+ draw = item.set_hover(event)
+ if draw:
+ self.figure.canvas.draw()
+ break
 
- if draw:
- print 'draw'
- self.figure.canvas.draw()
 
-
 fig = plt.figure()
-menu = Menu(fig, ('open', 'close', 'save', 'save as', 'quit'))
+fig.subplots_adjust(left=0.3)
+props = ItemProperties(labelcolor='black', bgcolor='yellow',
+ fontsize=15, alpha=0.2)
+hoverprops = ItemProperties(labelcolor='white', bgcolor='blue',
+ fontsize=15, alpha=0.2)
 
+menuitems = []
+for label in ('open', 'close', 'save', 'save as', 'quit'):
+ def on_select(item):
+ print 'you selected', item.labelstr
+ item = MenuItem(fig, label, props=props, hoverprops=hoverprops, on_select=on_select)
+ menuitems.append(item)
+
+menu = Menu(fig, menuitems)
 plt.show()
 
 
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -813,8 +813,9 @@
 a.set_figure(self.figure)
 if not a.is_transform_set():
 a.set_transform(self.transData)
- a.axes = self
 
+ a.set_axes(self)
+
 def _gen_axes_patch(self):
 """
 Returns the patch used to draw the background of the axes. It
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -202,6 +202,14 @@
 frameon=frameon,
 FigureClass=FigureClass,
 **kwargs)
+
+ # make this figure current on button press event
+ def make_active(event):
+ _pylab_helpers.Gcf.set_active(figManager)
+
+ cid = figManager.canvas.mpl_connect('button_press_event', make_active)
+ figManager._cidgcf = cid
+
 _pylab_helpers.Gcf.set_active(figManager)
 figManager.canvas.figure.number = num
 
@@ -252,17 +260,21 @@
 if len(args)==0:
 figManager = _pylab_helpers.Gcf.get_active()
 if figManager is None: return
- else: _pylab_helpers.Gcf.destroy(figManager.num)
+ else:
+ figManager.canvas.mpl_disconnect(figManager._cidgcf)
+ _pylab_helpers.Gcf.destroy(figManager.num)
 elif len(args)==1:
 arg = args[0]
 if arg=='all':
 for manager in _pylab_helpers.Gcf.get_all_fig_managers():
+ manager.canvas.mpl_disconnect(manager._cidgcf)
 _pylab_helpers.Gcf.destroy(manager.num)
 elif isinstance(arg, int):
 _pylab_helpers.Gcf.destroy(arg)
 elif isinstance(arg, Figure):
 for manager in _pylab_helpers.Gcf.get_all_fig_managers():
 if manager.canvas.figure==arg:
+ manager.canvas.mpl_disconnect(manager._cidgcf)
 _pylab_helpers.Gcf.destroy(manager.num)
 else:
 raise TypeError('Unrecognized argument type %s to close'%type(arg))
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/src/_backend_agg.cpp	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -90,6 +90,20 @@
 return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
 }
 
+Py::Object BufferRegion::set_x(const Py::Tuple &args) {
+ args.verify_length(1);
+ size_t x = Py::Int( args[0] );
+ rect.x1 = x;
+ return Py::Object();
+}
+
+Py::Object BufferRegion::set_y(const Py::Tuple &args) {
+ args.verify_length(1);
+ size_t y = Py::Int( args[0] );
+ rect.y1 = y;
+ return Py::Object();
+}
+
 Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
 // owned=true to prevent memory leak
 Py_ssize_t length;
@@ -1608,6 +1622,13 @@
 behaviors().name("BufferRegion");
 behaviors().doc("A wrapper to pass agg buffer objects to and from the python level");
 
+
+ add_varargs_method("set_x", &BufferRegion::set_x,
+		 "set_x(x)");
+
+ add_varargs_method("set_y", &BufferRegion::set_y,
+		 "set_y(y)");
+
 add_varargs_method("to_string", &BufferRegion::to_string,
 		 "to_string()");
 add_varargs_method("to_string_argb", &BufferRegion::to_string_argb,
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/src/_backend_agg.h	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -102,6 +102,10 @@
 
 bool freemem;
 
+ // set the x and y corners of the rectangle
+ Py::Object set_x(const Py::Tuple &args);
+ Py::Object set_y(const Py::Tuple &args);
+
 Py::Object to_string(const Py::Tuple &args);
 Py::Object to_string_argb(const Py::Tuple &args);
 static void init_type(void);
Modified: trunk/matplotlib/unit/memleak_hawaii3.py
===================================================================
--- trunk/matplotlib/unit/memleak_hawaii3.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/unit/memleak_hawaii3.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -2,15 +2,15 @@
 
 import os, sys, time, gc
 import matplotlib
-matplotlib.use('Agg')
+matplotlib.use('PDF')
 
 from matplotlib.cbook import report_memory
-import matplotlib.numerix as nx
+import numpy as np
 from pylab import figure, show, close
 
 # take a memory snapshot on indStart and compare it with indEnd
 
-rand = nx.mlab.rand
+rand = np.mlab.rand
 
 indStart, indEnd = 200, 401
 for i in range(indEnd):
@@ -19,8 +19,8 @@
 fig.clf()
 
 
- t1 = nx.arange(0.0, 2.0, 0.01)
- y1 = nx.sin(2*nx.pi*t1)
+ t1 = np.arange(0.0, 2.0, 0.01)
+ y1 = np.sin(2*np.pi*t1)
 y2 = rand(len(t1))
 X = rand(50,50)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 5 results of 5

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /