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
(4)
2
3
(8)
4
(16)
5
(40)
6
(16)
7
(9)
8
(15)
9
(6)
10
(4)
11
(28)
12
(6)
13
(2)
14
(7)
15
(8)
16
17
18
(9)
19
(2)
20
(7)
21
(3)
22
(6)
23
(25)
24
(16)
25
(8)
26
(7)
27
(3)
28
(1)
29
(4)
30
(21)
31
(15)





Showing 9 results of 9

From: <md...@us...> - 2009年08月07日 19:39:34
Revision: 7420
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7420&view=rev
Author: mdboom
Date: 2009年08月07日 19:39:27 +0000 (2009年8月07日)
Log Message:
-----------
Fix segfault in Agg backend
Modified Paths:
--------------
 trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2009年08月07日 18:33:02 UTC (rev 7419)
+++ trunk/matplotlib/src/_backend_agg.cpp	2009年08月07日 19:39:27 UTC (rev 7420)
@@ -1270,9 +1270,11 @@
 _VERBOSE("RendererAgg::draw_path_collection");
 args.verify_length(12);
 
- GCAgg gc(args[0], dpi);
+ Py::Object gc_obj = args[0];
+ GCAgg gc(gc_obj, dpi);
 agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[1].ptr());
- PathListGenerator paths(args[2]);
+ Py::SeqBase<Py::Object> path = args[2];
+ PathListGenerator path_generator(path);
 Py::SeqBase<Py::Object> transforms_obj = args[3];
 Py::Object offsets_obj = args[4];
 agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[5].ptr());
@@ -1283,7 +1285,6 @@
 Py::SeqBase<Py::Int> antialiaseds	 = args[10];
 // We don't actually care about urls for Agg, so just ignore it.
 // Py::SeqBase<Py::Object> urls = args[11];
- PathListGenerator path_generator(paths);
 
 try {
 _draw_path_collection_generic<PathListGenerator, 0, 1>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7419
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7419&view=rev
Author: jswhit
Date: 2009年08月07日 18:33:02 +0000 (2009年8月07日)
Log Message:
-----------
add extend='both'
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/contour_demo.py
Modified: trunk/toolkits/basemap/examples/contour_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/contour_demo.py	2009年08月07日 18:31:45 UTC (rev 7418)
+++ trunk/toolkits/basemap/examples/contour_demo.py	2009年08月07日 18:33:02 UTC (rev 7419)
@@ -22,7 +22,7 @@
 # create contour lines
 CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 # fill between contour lines.
-CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet)
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet,extend='both')
 # setup colorbar axes instance.
 pos = ax.get_position()
 l, b, w, h = pos.bounds
@@ -49,7 +49,7 @@
 # make a filled contour plot.
 x, y = m(lons, lats)
 CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet)
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet,extend='both')
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
@@ -75,7 +75,7 @@
 # make a filled contour plot.
 x, y = m(lons, lats)
 CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet)
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet,extend='both')
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
@@ -101,7 +101,7 @@
 # make a filled contour plot.
 x, y = m(lons, lats)
 CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS2 = m.contourf(x,y,hgt,CS2.levels,cmap=plt.cm.jet)
+CS2 = m.contourf(x,y,hgt,CS2.levels,cmap=plt.cm.jet,extend='both')
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
@@ -128,7 +128,7 @@
 # make a filled contour plot.
 x, y = m(lons, lats)
 CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS2 = m.contourf(x,y,hgt,CS2.levels,cmap=plt.cm.jet)
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet,extend='both')
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2009年08月07日 18:31:59
Revision: 7418
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7418&view=rev
Author: mdboom
Date: 2009年08月07日 18:31:45 +0000 (2009年8月07日)
Log Message:
-----------
Experimental Gouraud shading support in the Agg backend.
Modified Paths:
--------------
 trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
 trunk/matplotlib/lib/matplotlib/collections.py
 trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py	2009年08月07日 17:02:28 UTC (rev 7417)
+++ trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py	2009年08月07日 18:31:45 UTC (rev 7418)
@@ -28,7 +28,7 @@
 fig = figure()
 ax = fig.add_subplot(121)
 ax.set_axis_bgcolor("#bdb76b")
-ax.pcolormesh(Qx,Qz,Z)
+ax.pcolormesh(Qx,Qz,Z, shading='gouraud')
 ax.set_title('Without masked values')
 
 ax = fig.add_subplot(122)
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2009年08月07日 17:02:28 UTC (rev 7417)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2009年08月07日 18:31:45 UTC (rev 7418)
@@ -6543,7 +6543,7 @@
 and max of the color array *C* is used. If you pass a
 *norm* instance, *vmin* and *vmax* will be ignored.
 
- *shading*: [ 'flat' | 'faceted' ]
+ *shading*: [ 'flat' | 'faceted' | 'gouraud' ]
 If 'faceted', a black grid is drawn around each rectangle; if
 'flat', edges are not drawn. Default is 'flat', contrary to
 Matlab(TM).
@@ -6584,7 +6584,7 @@
 cmap = kwargs.pop('cmap', None)
 vmin = kwargs.pop('vmin', None)
 vmax = kwargs.pop('vmax', None)
- shading = kwargs.pop('shading', 'flat')
+ shading = kwargs.pop('shading', 'flat').lower()
 edgecolors = kwargs.pop('edgecolors', 'None')
 antialiased = kwargs.pop('antialiased', False)
 
@@ -6592,8 +6592,11 @@
 Ny, Nx = X.shape
 
 # convert to one dimensional arrays
- C = ma.ravel(C[0:Ny-1, 0:Nx-1]) # data point in each cell is value at
- # lower left corner
+ if shading != 'gouraud':
+ C = ma.ravel(C[0:Ny-1, 0:Nx-1]) # data point in each cell is value at
+ # lower left corner
+ else:
+ C = C.ravel()
 X = X.ravel()
 Y = Y.ravel()
 
@@ -6608,7 +6611,7 @@
 
 collection = mcoll.QuadMesh(
 Nx - 1, Ny - 1, coords, showedges,
- antialiased=antialiased) # kwargs are not used
+ antialiased=antialiased, shading=shading) # kwargs are not used
 collection.set_alpha(alpha)
 collection.set_array(C)
 if norm is not None: assert(isinstance(norm, mcolors.Normalize))
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2009年08月07日 17:02:28 UTC (rev 7417)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2009年08月07日 18:31:45 UTC (rev 7418)
@@ -166,6 +166,14 @@
 gc, master_transform, paths, [], offsets, offsetTrans, facecolors,
 edgecolors, linewidths, [], [antialiased], [None])
 
+ def draw_gouraud_triangle(self, gc, points, colors, transform):
+ """
+ Draw a Gouraud-shaded triangle.
+
+ EXPERIMENTAL
+ """
+ raise NotImplementedError
+
 def _iter_collection_raw_paths(self, master_transform, paths,
 all_transforms):
 """
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2009年08月07日 17:02:28 UTC (rev 7417)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2009年08月07日 18:31:45 UTC (rev 7418)
@@ -63,6 +63,7 @@
 self.draw_markers = self._renderer.draw_markers
 self.draw_path_collection = self._renderer.draw_path_collection
 self.draw_quad_mesh = self._renderer.draw_quad_mesh
+ self.draw_gouraud_triangle = self._renderer.draw_gouraud_triangle
 self.draw_image = self._renderer.draw_image
 self.copy_from_bbox = self._renderer.copy_from_bbox
 self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py	2009年08月07日 17:02:28 UTC (rev 7417)
+++ trunk/matplotlib/lib/matplotlib/collections.py	2009年08月07日 18:31:45 UTC (rev 7418)
@@ -1073,14 +1073,18 @@
 coordinates of the vertex at mesh coordinates (0, 0), then the one
 at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and
 so on.
+
+ *shading* may be 'flat', 'faceted' or 'gouraud'
 """
- def __init__(self, meshWidth, meshHeight, coordinates, showedges, antialiased=True):
+ def __init__(self, meshWidth, meshHeight, coordinates, showedges,
+ antialiased=True, shading='flat'):
 Collection.__init__(self)
 self._meshWidth = meshWidth
 self._meshHeight = meshHeight
 self._coordinates = coordinates
 self._showedges = showedges
 self._antialiased = antialiased
+ self._shading = shading
 
 self._bbox = transforms.Bbox.unit()
 self._bbox.update_from_data_xy(coordinates.reshape(
@@ -1125,6 +1129,46 @@
 points = points.reshape((meshWidth * meshHeight, 5, 2))
 return [Path(x) for x in points]
 
+ def convert_mesh_to_triangles(self, meshWidth, meshHeight, coordinates):
+ """
+ Converts a given mesh into a sequence of triangles, each point
+ with its own color
+ :class:`matplotlib.path.Path` objects for easier rendering by
+ backends that do not directly support quadmeshes.
+
+ This function is primarily of use to backend implementers.
+ """
+ Path = mpath.Path
+
+ if ma.isMaskedArray(coordinates):
+ c = coordinates.data
+ else:
+ c = coordinates
+
+ triangles = np.concatenate((
+ c[0:-1, 0:-1],
+ c[0:-1, 1: ],
+ c[1: , 1: ],
+ c[1: , 1: ],
+ c[1: , 0:-1],
+ c[0:-1, 0:-1]
+ ), axis=2)
+ triangles = triangles.reshape((meshWidth * meshHeight * 2, 3, 2))
+
+ c = self.get_facecolor().reshape((meshHeight + 1, meshWidth + 1, 4))
+ colors = np.concatenate((
+ c[0:-1, 0:-1],
+ c[0:-1, 1: ],
+ c[1: , 1: ],
+ c[1: , 1: ],
+ c[1: , 0:-1],
+ c[0:-1, 0:-1]
+ ), axis=2)
+
+ colors = colors.reshape((meshWidth * meshHeight * 2, 3, 4))
+
+ return triangles, colors
+
 def get_datalim(self, transData):
 return self._bbox
 
@@ -1166,10 +1210,17 @@
 gc.set_clip_rectangle(self.get_clip_box())
 gc.set_clip_path(self.get_clip_path())
 
- renderer.draw_quad_mesh(
- gc, transform.frozen(), self._meshWidth, self._meshHeight,
- coordinates, offsets, transOffset, self.get_facecolor(),
- self._antialiased, self._showedges)
+ if self._shading == 'gouraud':
+ triangles, colors = self.convert_mesh_to_triangles(
+ self._meshWidth, self._meshHeight, coordinates)
+ check = {}
+ for tri, col in zip(triangles, colors):
+ renderer.draw_gouraud_triangle(gc, tri, col, transform.frozen())
+ else:
+ renderer.draw_quad_mesh(
+ gc, transform.frozen(), self._meshWidth, self._meshHeight,
+ coordinates, offsets, transOffset, self.get_facecolor(),
+ self._antialiased, self._showedges)
 renderer.close_group(self.__class__.__name__)
 
 
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2009年08月07日 17:02:28 UTC (rev 7417)
+++ trunk/matplotlib/src/_backend_agg.cpp	2009年08月07日 18:31:45 UTC (rev 7418)
@@ -1464,11 +1464,14 @@
 typedef agg::span_allocator<color_t> span_alloc_t;
 
 //segments, trans, clipbox, colors, linewidths, antialiaseds
- GCAgg gc(args[0], dpi);
- Py::Object points_obj = args[1];
- Py::Object colors_obj = args[2];
- agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[3].ptr());
+ GCAgg gc(args[0], dpi);
+ Py::Object points_obj = args[1];
+ Py::Object colors_obj = args[2];
+ agg::trans_affine trans = py_to_agg_transformation_matrix(args[3].ptr());
 
+ trans *= agg::trans_affine_scaling(1.0, -1.0);
+ trans *= agg::trans_affine_translation(0.0, (double)height);
+
 PyArrayObject* points = (PyArrayObject*)PyArray_ContiguousFromAny
 (points_obj.ptr(), PyArray_DOUBLE, 2, 2);
 if (!points ||
@@ -1489,7 +1492,7 @@
 for (int i = 0; i < 6; i += 2) {
 tpoints[i] = opoints[i];
 tpoints[i+1] = opoints[i+1];
- master_transform.transform(&tpoints[i], &tpoints[i+1]);
+ trans.transform(&tpoints[i], &tpoints[i+1]);
 }
 
 span_alloc_t span_alloc;
@@ -1503,7 +1506,7 @@
 tpoints[0], tpoints[1],
 tpoints[2], tpoints[3],
 tpoints[4], tpoints[5],
- 1.0);
+ 0.5);
 
 theRasterizer.add_path(span_gen);
 agg::render_scanlines_aa(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2009年08月07日 17:02:37
Revision: 7417
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7417&view=rev
Author: mdboom
Date: 2009年08月07日 17:02:28 +0000 (2009年8月07日)
Log Message:
-----------
Refactor some backend methods for consistency and to reduce explosion of the number of arguments. A first crack at Gouraud shading in the Agg backend (not hooked up to anything).
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/doc/api/api_changes.rst
 trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
 trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
 trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
 trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py
 trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py
 trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
 trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
 trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
 trunk/matplotlib/lib/matplotlib/backends/backend_template.py
 trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
 trunk/matplotlib/lib/matplotlib/collections.py
 trunk/matplotlib/lib/matplotlib/figure.py
 trunk/matplotlib/lib/matplotlib/font_manager.py
 trunk/matplotlib/lib/matplotlib/image.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_backend_agg.h
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/CHANGELOG	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -1,3 +1,41 @@
+2009年08月07日 In an effort to simplify the backend API, all clipping rectangles
+ and paths are now passed in using GraphicsContext objects, even
+ on collections and images. Therefore:
+
+ draw_path_collection(self, master_transform, cliprect, clippath,
+ clippath_trans, paths, all_transforms, offsets,
+ offsetTrans, facecolors, edgecolors, linewidths,
+ linestyles, antialiaseds, urls)
+
+ becomes:
+
+ draw_path_collection(self, gc, master_transform, paths, all_transforms,
+ offsets, offsetTrans, facecolors, edgecolors,
+ linewidths, linestyles, antialiaseds, urls)
+
+
+
+ draw_quad_mesh(self, master_transform, cliprect, clippath,
+ clippath_trans, meshWidth, meshHeight, coordinates,
+ offsets, offsetTrans, facecolors, antialiased,
+ showedges)
+
+ becomes:
+
+ draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
+ coordinates, offsets, offsetTrans, facecolors,
+ antialiased, showedges)
+
+
+
+ draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None)
+
+ becomes:
+
+ draw_image(self, gc, x, y, im)
+
+ - MGD
+
 2009年08月06日 Tagging the 0.99.0 release at svn r7397 - JDH
 
 	 * fixed an alpha colormapping bug posted on sf 2832575
@@ -30,7 +68,6 @@
 
 	 * apply sf patches 2830233 and 2823885 for osx setup and 64 bit; thanks Michiel
 
-
 2009年08月04日 Made cbook.get_sample_data make use of the ETag and Last-Modified
 headers of mod_dav_svn. - JKS
 
Modified: trunk/matplotlib/doc/api/api_changes.rst
===================================================================
--- trunk/matplotlib/doc/api/api_changes.rst	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/doc/api/api_changes.rst	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -18,6 +18,43 @@
 .. _configobj: http://www.voidspace.org.uk/python/configobj.html
 .. _`enthought.traits`: http://code.enthought.com/projects/traits
 
+Changes beyond 0.99.x
+=====================
+
+In an effort to simplify the backend API, all clipping rectangles
+and paths are now passed in using GraphicsContext objects, even
+on collections and images. Therefore::
+
+ draw_path_collection(self, master_transform, cliprect, clippath,
+ clippath_trans, paths, all_transforms, offsets,
+ offsetTrans, facecolors, edgecolors, linewidths,
+ linestyles, antialiaseds, urls)
+
+ # is now
+
+ draw_path_collection(self, gc, master_transform, paths, all_transforms,
+ offsets, offsetTrans, facecolors, edgecolors,
+ linewidths, linestyles, antialiaseds, urls)
+
+
+ draw_quad_mesh(self, master_transform, cliprect, clippath,
+ clippath_trans, meshWidth, meshHeight, coordinates,
+ offsets, offsetTrans, facecolors, antialiased,
+ showedges)
+
+ # is now
+
+ draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
+ coordinates, offsets, offsetTrans, facecolors,
+ antialiased, showedges)
+
+
+ draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None)
+
+ # is now
+
+ draw_image(self, gc, x, y, im)
+
 Changes in 0.99
 ======================
 
Modified: trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -11,7 +11,7 @@
 from matplotlib import cm, colors
 from numpy import ma
 
-n = 56
+n = 12
 x = np.linspace(-1.5,1.5,n)
 y = np.linspace(-1.5,1.5,n*2)
 X,Y = np.meshgrid(x,y);
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -1705,12 +1705,14 @@
 l, b, w, h = self.bbox.bounds
 # composite images need special args so they will not
 # respect z-order for now
- renderer.draw_image(
- round(l), round(b), im, self.bbox,
- self.patch.get_path(),
- self.patch.get_transform())
 
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.bbox)
+ gc.set_clip_path(mtransforms.TransformedPath(
+ self.patch.get_path(),
+ self.patch.get_transform()))
 
+ renderer.draw_image(gc, round(l), round(b), im)
 
 if dsu_rasterized:
 for zorder, i, a in dsu_rasterized:
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -108,24 +108,23 @@
 marker_trans + transforms.Affine2D().translate(x, y),
 rgbFace)
 
- def draw_path_collection(self, master_transform, cliprect, clippath,
- clippath_trans, paths, all_transforms, offsets,
- offsetTrans, facecolors, edgecolors, linewidths,
- linestyles, antialiaseds, urls):
+ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
+ offsets, offsetTrans, facecolors, edgecolors,
+ linewidths, linestyles, antialiaseds, urls):
 """
- Draws a collection of paths, selecting drawing properties from
+ Draws a collection of paths selecting drawing properties from
 the lists *facecolors*, *edgecolors*, *linewidths*,
 *linestyles* and *antialiaseds*. *offsets* is a list of
 offsets to apply to each of the paths. The offsets in
- *offsets* are first transformed by *offsetTrans* before
- being applied.
+ *offsets* are first transformed by *offsetTrans* before being
+ applied.
 
 This provides a fallback implementation of
 :meth:`draw_path_collection` that makes multiple calls to
- draw_path. Some backends may want to override this in order
- to render each set of path data only once, and then reference
- that path multiple times with the different offsets, colors,
- styles etc. The generator methods
+ :meth:`draw_path`. Some backends may want to override this in
+ order to render each set of path data only once, and then
+ reference that path multiple times with the different offsets,
+ colors, styles etc. The generator methods
 :meth:`_iter_collection_raw_paths` and
 :meth:`_iter_collection` are provided to help with (and
 standardize) the implementation across backends. It is highly
@@ -137,18 +136,16 @@
 master_transform, paths, all_transforms):
 path_ids.append((path, transform))
 
- for xo, yo, path_id, gc, rgbFace in self._iter_collection(
- path_ids, cliprect, clippath, clippath_trans,
- offsets, offsetTrans, facecolors, edgecolors,
+ for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
+ gc, path_ids, offsets, offsetTrans, facecolors, edgecolors,
 linewidths, linestyles, antialiaseds, urls):
 path, transform = path_id
 transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo)
- self.draw_path(gc, path, transform, rgbFace)
+ self.draw_path(gc0, path, transform, rgbFace)
 
- def draw_quad_mesh(self, master_transform, cliprect, clippath,
- clippath_trans, meshWidth, meshHeight, coordinates,
- offsets, offsetTrans, facecolors, antialiased,
- showedges):
+ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
+ coordinates, offsets, offsetTrans, facecolors,
+ antialiased, showedges):
 """
 This provides a fallback implementation of
 :meth:`draw_quad_mesh` that generates paths and then calls
@@ -166,11 +163,11 @@
 linewidths = np.array([0.0], np.float_)
 
 return self.draw_path_collection(
- master_transform, cliprect, clippath, clippath_trans,
- paths, [], offsets, offsetTrans, facecolors, edgecolors,
- linewidths, [], [antialiased], [None])
+ gc, master_transform, paths, [], offsets, offsetTrans, facecolors,
+ edgecolors, linewidths, [], [antialiased], [None])
 
- def _iter_collection_raw_paths(self, master_transform, paths, all_transforms):
+ def _iter_collection_raw_paths(self, master_transform, paths,
+ all_transforms):
 """
 This is a helper method (along with :meth:`_iter_collection`) to make
 it easier to write a space-efficent :meth:`draw_path_collection`
@@ -200,9 +197,9 @@
 transform = all_transforms[i % Ntransforms]
 yield path, transform + master_transform
 
- def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,
- offsets, offsetTrans, facecolors, edgecolors,
- linewidths, linestyles, antialiaseds, urls):
+ def _iter_collection(self, gc, path_ids, offsets, offsetTrans, facecolors,
+ edgecolors, linewidths, linestyles, antialiaseds,
+ urls):
 """
 This is a helper method (along with
 :meth:`_iter_collection_raw_paths`) to make it easier to write
@@ -243,18 +240,14 @@
 if Noffsets:
 toffsets = offsetTrans.transform(offsets)
 
- gc = self.new_gc()
+ gc0 = self.new_gc()
+ gc0.copy_properties(gc)
 
- gc.set_clip_rectangle(cliprect)
- if clippath is not None:
- clippath = transforms.TransformedPath(clippath, clippath_trans)
- gc.set_clip_path(clippath)
-
 if Nfacecolors == 0:
 rgbFace = None
 
 if Nedgecolors == 0:
- gc.set_linewidth(0.0)
+ gc0.set_linewidth(0.0)
 
 xo, yo = 0, 0
 for i in xrange(N):
@@ -264,20 +257,20 @@
 if Nfacecolors:
 rgbFace = facecolors[i % Nfacecolors]
 if Nedgecolors:
- gc.set_foreground(edgecolors[i % Nedgecolors])
+ gc0.set_foreground(edgecolors[i % Nedgecolors])
 if Nlinewidths:
- gc.set_linewidth(linewidths[i % Nlinewidths])
+ gc0.set_linewidth(linewidths[i % Nlinewidths])
 if Nlinestyles:
- gc.set_dashes(*linestyles[i % Nlinestyles])
+ gc0.set_dashes(*linestyles[i % Nlinestyles])
 if rgbFace is not None and len(rgbFace)==4:
- gc.set_alpha(rgbFace[-1])
+ gc0.set_alpha(rgbFace[-1])
 rgbFace = rgbFace[:3]
- gc.set_antialiased(antialiaseds[i % Naa])
+ gc0.set_antialiased(antialiaseds[i % Naa])
 if Nurls:
- gc.set_url(urls[i % Nurls])
+ gc0.set_url(urls[i % Nurls])
 
- yield xo, yo, path_id, gc, rgbFace
- gc.restore()
+ yield xo, yo, path_id, gc0, rgbFace
+ gc0.restore()
 
 def get_image_magnification(self):
 """
@@ -287,10 +280,13 @@
 """
 return 1.0
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
 """
 Draw the image instance into the current axes;
 
+ *gc*
+ a GraphicsContext containing clipping information
+
 *x*
 is the distance in pixels from the left hand side of the canvas.
 
@@ -301,11 +297,6 @@
 
 *im*
 the :class:`matplotlib._image.Image` instance
-
- *bbox*
- a :class:`matplotlib.transforms.Bbox` instance for clipping, or
- None
-
 """
 raise NotImplementedError
 
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -250,7 +250,7 @@
 >>> x1, y1, x2, y2 = region.get_extents()
 >>> renderer.restore_region(region, bbox=(x1+dx, y1, x2, y2),
 xy=(x1-dx, y1))
- 
+
 """
 if bbox is not None or xy is not None:
 if bbox is None:
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -151,10 +151,12 @@
 
 self._fill_and_stroke(ctx, rgbFace, gc.get_alpha())
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
 # bbox - not currently used
 if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
 
+ clippath, clippath_trans = gc.get_clip_path()
+
 im.flipud_out()
 
 rows, cols, buf = im.color_conv (BYTE_FORMAT)
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -97,7 +97,9 @@
 if gc.gdkGC.line_width > 0:
 self.gdkDrawable.draw_lines(gc.gdkGC, polygon)
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
+ bbox = gc.get_clip_rectangle()
+
 if bbox != None:
 l,b,w,h = bbox.bounds
 #rectangle = (int(l), self.height-int(b+h),
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -59,12 +59,19 @@
 gc.draw_markers(marker_path, marker_trans, path, trans, rgbFace)
 
 def draw_path_collection(self, *args):
- gc = self.gc
- args = args[:13]
+ # TODO: We should change this in the C code eventually, but this
+ # re-ordering of arguments should work for now
+ gc = args[0]
+ args = tuple([gc, args[1], gc.get_clip_rectangle()] + \
+ list(gc.get_clip_path()) + list(args[2:]))
 gc.draw_path_collection(*args)
 
 def draw_quad_mesh(self, *args):
- gc = self.gc
+ # TODO: We should change this in the C code eventually, but this
+ # re-ordering of arguments should work for now
+ gc = args[0]
+ args = [gc, args[1], gc.get_clip_rectangle()] + \
+ list(gc.get_clip_path()) + list(args[2:])
 gc.draw_quad_mesh(*args)
 
 def new_gc(self):
@@ -72,12 +79,15 @@
 self.gc.set_hatch(None)
 return self.gc
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
+ # TODO: We should change this in the C code eventually, but this
+ # re-ordering of arguments should work for now
 im.flipud_out()
 nrows, ncols, data = im.as_rgba_str()
- self.gc.draw_image(x, y, nrows, ncols, data, bbox, clippath, clippath_trans)
+ gc.draw_image(x, y, nrows, ncols, data, gc.get_clip_rectangle(),
+ *gc.get_clip_path())
 im.flipud_out()
- 
+
 def draw_tex(self, gc, x, y, s, prop, angle):
 # todo, handle props, angle, origins
 size = prop.get_size_in_points()
@@ -128,7 +138,7 @@
 
 def flipy(self):
 return False
- 
+
 def points_to_pixels(self, points):
 return points/72.0 * self.dpi
 
@@ -168,7 +178,7 @@
 _macosx.GraphicsContext.set_clip_path(self, path)
 
 ########################################################################
-# 
+#
 # The following functions and classes are for pylab and implement
 # window/figure managers, etc...
 #
@@ -281,7 +291,7 @@
 self.toolbar = NavigationToolbar2Mac(canvas)
 else:
 self.toolbar = None
- if self.toolbar is not None: 
+ if self.toolbar is not None:
 self.toolbar.update()
 
 def notify_axes_change(fig):
@@ -300,7 +310,7 @@
 Gcf.destroy(self.num)
 
 class NavigationToolbarMac(_macosx.NavigationToolbar):
- 
+
 def __init__(self, canvas):
 self.canvas = canvas
 basedir = os.path.join(matplotlib.rcParams['datapath'], "images")
@@ -331,7 +341,7 @@
 assert magic=="P6"
 assert len(imagedata)==width*height*3 # 3 colors in RGB
 return (width, height, imagedata)
- 
+
 def panx(self, direction):
 axes = self.canvas.figure.axes
 selected = self.get_active()
@@ -401,9 +411,9 @@
 _macosx.NavigationToolbar2.set_message(self, message.encode('utf-8'))
 
 ########################################################################
-# 
+#
 # Now just provide the standard names that backend.__init__ is expecting
-# 
+#
 ########################################################################
 
 
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -14,7 +14,7 @@
 raster_renderer_class=None,
 bbox_inches_restore=None):
 """
- figure: The figure instance. 
+ figure: The figure instance.
 
 width: The width of the canvas in logical units
 
@@ -49,7 +49,7 @@
 self.figure=figure
 
 self._bbox_inches_restore = bbox_inches_restore
- 
+
 self._set_current_renderer(vector_renderer)
 
 _methods = """
@@ -88,8 +88,8 @@
 mode="png")
 
 self._bbox_inches_restore = r
- 
- 
+
+
 if self._rasterizing == 0:
 self._raster_renderer = self._raster_renderer_class(
 self._width*self.dpi, self._height*self.dpi, self.dpi)
@@ -117,9 +117,12 @@
 image = frombuffer(buffer, w, h, True)
 image.is_grayscale = False
 image.flipud_out()
- self._renderer.draw_image(int(float(l)/self.dpi*72.),
- int((float(height) - b - h)/self.dpi*72.),
- image, None)
+ gc = self._renderer.new_gc()
+ self._renderer.draw_image(
+ gc,
+ int(float(l)/self.dpi*72.),
+ int((float(height) - b - h)/self.dpi*72.),
+ image)
 self._raster_renderer = None
 self._rasterizing = False
 
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -1286,13 +1286,7 @@
 def get_image_magnification(self):
 return self.image_dpi/72.0
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
- gc = self.new_gc()
- if bbox is not None:
- gc.set_clip_rectangle(bbox)
- if clippath is not None:
- clippath = TransformedPath(clippath, clippath_trans)
- gc.set_clip_path(clippath)
+ def draw_image(self, gc, x, y, im):
 self.check_gc(gc)
 
 h, w = im.get_size_out()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -374,7 +374,7 @@
 """
 return self.image_magnification
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
 """
 Draw the Image instance into the current axes; x is the
 distance in pixels from the left hand side of the canvas and y
@@ -400,6 +400,9 @@
 figh = self.height*72
 #print 'values', origin, flipud, figh, h, y
 
+ bbox = gc.get_clip_rectangle()
+ clippath, clippath_trans = gc.get_clip_path()
+
 clip = []
 if bbox is not None:
 clipx,clipy,clipw,cliph = bbox.bounds
@@ -504,10 +507,9 @@
 ps = '\n'.join(ps_cmd)
 self._draw_ps(ps, gc, rgbFace, fill=False, stroke=False)
 
- def draw_path_collection(self, master_transform, cliprect, clippath,
- clippath_trans, paths, all_transforms, offsets,
- offsetTrans, facecolors, edgecolors, linewidths,
- linestyles, antialiaseds, urls):
+ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
+ offsets, offsetTrans, facecolors, edgecolors,
+ linewidths, linestyles, antialiaseds, urls):
 write = self._pswriter.write
 
 path_codes = []
@@ -521,13 +523,11 @@
 write('\n'.join(ps_cmd))
 path_codes.append(name)
 
- for xo, yo, path_id, gc, rgbFace in self._iter_collection(
- path_codes, cliprect, clippath, clippath_trans,
- offsets, offsetTrans, facecolors, edgecolors,
+ for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
+ gc, path_codes, offsets, offsetTrans, facecolors, edgecolors,
 linewidths, linestyles, antialiaseds, urls):
-
 ps = "%g %g %s" % (xo, yo, path_id)
- self._draw_ps(ps, gc, rgbFace)
+ self._draw_ps(ps, gc0, rgbFace)
 
 self._path_collection_id += 1
 
@@ -964,7 +964,7 @@
 class NullWriter(object):
 def write(self, *kl, **kwargs):
 pass
- 
+
 self._pswriter = NullWriter()
 else:
 self._pswriter = StringIO()
@@ -1096,7 +1096,7 @@
 class NullWriter(object):
 def write(self, *kl, **kwargs):
 pass
- 
+
 self._pswriter = NullWriter()
 else:
 self._pswriter = StringIO()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -262,10 +262,9 @@
 self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details))
 write('</g>')
 
- def draw_path_collection(self, master_transform, cliprect, clippath,
- clippath_trans, paths, all_transforms, offsets,
- offsetTrans, facecolors, edgecolors, linewidths,
- linestyles, antialiaseds, urls):
+ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
+ offsets, offsetTrans, facecolors, edgecolors,
+ linewidths, linestyles, antialiaseds, urls):
 write = self._svgwriter.write
 
 path_codes = []
@@ -280,18 +279,17 @@
 path_codes.append(name)
 write('</defs>\n')
 
- for xo, yo, path_id, gc, rgbFace in self._iter_collection(
- path_codes, cliprect, clippath, clippath_trans,
- offsets, offsetTrans, facecolors, edgecolors,
+ for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
+ gc, path_codes, offsets, offsetTrans, facecolors, edgecolors,
 linewidths, linestyles, antialiaseds, urls):
- clipid = self._get_gc_clip_svg(gc)
- url = gc.get_url()
+ clipid = self._get_gc_clip_svg(gc0)
+ url = gc0.get_url()
 if url is not None:
 self._svgwriter.write('<a xlink:href="%s">' % url)
 if clipid is not None:
 write('<g clip-path="url(#%s)">' % clipid)
 details = 'xlink:href="#%s" x="%f" y="%f"' % (path_id, xo, self.height - yo)
- style = self._get_style(gc, rgbFace)
+ style = self._get_style(gc0, rgbFace)
 self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details))
 if clipid is not None:
 write('</g>')
@@ -300,7 +298,7 @@
 
 self._path_collection_id += 1
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
 # MGDTODO: Support clippath here
 trans = [1,0,0,1,0,0]
 transstr = ''
@@ -643,7 +641,7 @@
 # the problem. I hope someone who knows the svg backends
 # take a look at this problem. Meanwhile, the dpi
 # parameter is ignored and image_dpi is fixed at 72. - JJL
- 
+
 #image_dpi = kwargs.pop("dpi", 72)
 image_dpi = 72
 _bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_template.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_template.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_template.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -87,22 +87,21 @@
 # draw_path_collection is optional, and we get more correct
 # relative timings by leaving it out. backend implementers concerned with
 # performance will probably want to implement it
-# def draw_path_collection(self, master_transform, cliprect, clippath,
-# clippath_trans, paths, all_transforms, offsets,
-# offsetTrans, facecolors, edgecolors, linewidths,
-# linestyles, antialiaseds):
+# def draw_path_collection(self, gc, master_transform, paths,
+# all_transforms, offsets, offsetTrans, facecolors,
+# edgecolors, linewidths, linestyles,
+# antialiaseds):
 # pass
 
 # draw_quad_mesh is optional, and we get more correct
 # relative timings by leaving it out. backend implementers concerned with
 # performance will probably want to implement it
-# def draw_quad_mesh(self, master_transform, cliprect, clippath,
-# clippath_trans, meshWidth, meshHeight, coordinates,
-# offsets, offsetTrans, facecolors, antialiased,
-# showedges):
+# def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
+# coordinates, offsets, offsetTrans, facecolors,
+# antialiased, showedges):
 # pass
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
 pass
 
 def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -361,7 +361,8 @@
 gfx_ctx.StrokePath(wxpath)
 gc.unselect()
 
- def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ def draw_image(self, gc, x, y, im):
+ bbox = gc.get_clip_rectangle()
 if bbox != None:
 l,b,w,h = bbox.bounds
 else:
@@ -776,7 +777,7 @@
 bind(self, wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown)
 bind(self, wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDown)
 bind(self, wx.EVT_MIDDLE_UP, self._onMiddleButtonUp)
-	
+
 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
 
 self.macros = {} # dict from wx id to seq of macros
@@ -1257,7 +1258,7 @@
 if self.HasCapture(): self.ReleaseMouse()
 FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
 
- #Add middle button events	
+ #Add middle button events
 def _onMiddleButtonDown(self, evt):
 """Start measuring on an axis."""
 x = evt.GetX()
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/collections.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -204,18 +204,16 @@
 
 self.update_scalarmappable()
 
- clippath, clippath_trans = self.get_transformed_clip_path_and_affine()
- if clippath_trans is not None:
- clippath_trans = clippath_trans.frozen()
-
 transform, transOffset, offsets, paths = self._prepare_points()
 
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.get_clip_box())
+ gc.set_clip_path(self.get_clip_path())
+
 renderer.draw_path_collection(
- transform.frozen(), self.clipbox, clippath, clippath_trans,
- paths, self.get_transforms(),
- offsets, transOffset,
- self.get_facecolor(), self.get_edgecolor(), self._linewidths,
- self._linestyles, self._antialiaseds, self._urls)
+ gc, transform.frozen(), paths, self.get_transforms(),
+ offsets, transOffset, self.get_facecolor(), self.get_edgecolor(),
+ self._linewidths, self._linestyles, self._antialiaseds, self._urls)
 renderer.close_group(self.__class__.__name__)
 
 def contains(self, mouseevent):
@@ -1149,10 +1147,6 @@
 if self.check_update('array'):
 self.update_scalarmappable()
 
- clippath, clippath_trans = self.get_transformed_clip_path_and_affine()
- if clippath_trans is not None:
- clippath_trans = clippath_trans.frozen()
-
 if not transform.is_affine:
 coordinates = self._coordinates.reshape(
 (self._coordinates.shape[0] *
@@ -1168,11 +1162,14 @@
 offsets = transOffset.transform_non_affine(offsets)
 transOffset = transOffset.get_affine()
 
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.get_clip_box())
+ gc.set_clip_path(self.get_clip_path())
+
 renderer.draw_quad_mesh(
- transform.frozen(), self.clipbox, clippath, clippath_trans,
- self._meshWidth, self._meshHeight, coordinates,
- offsets, transOffset, self.get_facecolor(), self._antialiased,
- self._showedges)
+ gc, transform.frozen(), self._meshWidth, self._meshHeight,
+ coordinates, offsets, transOffset, self.get_facecolor(),
+ self._antialiased, self._showedges)
 renderer.close_group(self.__class__.__name__)
 
 
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/figure.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -766,9 +766,10 @@
 
 im.is_grayscale = False
 l, b, w, h = self.bbox.bounds
- clippath, affine = self.get_transformed_clip_path_and_affine()
- renderer.draw_image(l, b, im, self.bbox,
- clippath, affine)
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.bbox)
+ gc.set_clip_path(self.get_clip_path())
+ renderer.draw_image(gc, l, b, im)
 
 # render the axes
 for a in self.axes: a.draw(renderer)
@@ -851,7 +852,7 @@
 
 *fancybox*: [ None | False | True ]
 if True, draw a frame with a round fancybox. If None, use rc
- 
+
 *shadow*: [ None | False | True ]
 If *True*, draw a shadow behind legend. If *None*, use rc settings.
 
Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -707,7 +707,7 @@
 def __hash__(self):
 l = [(k, getattr(self, "get" + k)()) for k in sorted(self.__dict__)]
 return hash(repr(l))
- 
+
 def __str__(self):
 return self.get_fontconfig_pattern()
 
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/lib/matplotlib/image.py	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -235,9 +235,10 @@
 im = self.make_image(renderer.get_image_magnification())
 im._url = self.get_url()
 l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
- clippath, affine = self.get_transformed_clip_path_and_affine()
- renderer.draw_image(round(l), round(b), im, self.axes.bbox.frozen(),
- clippath, affine)
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.axes.bbox.frozen())
+ gc.set_clip_path(self.get_clip_path())
+ renderer.draw_image(gc, round(l), round(b), im)
 
 def contains(self, mouseevent):
 """
@@ -576,11 +577,13 @@
 def draw(self, renderer, *args, **kwargs):
 if not self.get_visible(): return
 im = self.make_image(renderer.get_image_magnification())
- renderer.draw_image(round(self.axes.bbox.xmin),
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.axes.bbox.frozen())
+ gc.set_clip_path(self.get_clip_path())
+ renderer.draw_image(gc,
+ round(self.axes.bbox.xmin),
 round(self.axes.bbox.ymin),
- im,
- self.axes.bbox.frozen(),
- *self.get_transformed_clip_path_and_affine())
+ im)
 
 
 def set_data(self, x, y, A):
@@ -730,8 +733,10 @@
 if not self.get_visible(): return
 # todo: we should be able to do some cacheing here
 im = self.make_image(renderer.get_image_magnification())
- renderer.draw_image(round(self.ox), round(self.oy), im, self.figure.bbox,
- *self.get_transformed_clip_path_and_affine())
+ gc = renderer.new_gc()
+ gc.set_clip_rectangle(self.figure.bbox)
+ gc.set_clip_path(self.get_clip_path())
+ renderer.draw_image(gc, round(self.ox), round(self.oy), im)
 
 def write_png(self, fname):
 """Write the image to png file with fname"""
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/src/_backend_agg.cpp	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -31,6 +31,7 @@
 #include "agg_span_image_filter_rgba.h"
 #include "agg_span_interpolator_linear.h"
 #include "agg_span_pattern_rgba.h"
+#include "agg_span_gouraud_rgba.h"
 #include "agg_conv_shorten_path.h"
 #include "util/agg_color_conv_rgb8.h"
 
@@ -799,23 +800,17 @@
 RendererAgg::draw_image(const Py::Tuple& args) {
 _VERBOSE("RendererAgg::draw_image");
 
- args.verify_length(4, 6);
+ args.verify_length(4);
 
- double x = Py::Float(args[0]);
- double y = Py::Float(args[1]);
- Image *image = static_cast<Image*>(args[2].ptr());
- Py::Object box_obj = args[3];
- Py::Object clippath;
- agg::trans_affine clippath_trans;
+ GCAgg gc(args[0], dpi);
+ double x = Py::Float(args[1]);
+ double y = Py::Float(args[2]);
+ Image *image = static_cast<Image*>(args[3].ptr());
 bool has_clippath = false;
 
 theRasterizer.reset_clipping();
 rendererBase.reset_clipping(true);
- if (args.size() == 6) {
- clippath = args[4];
- clippath_trans = py_to_agg_transformation_matrix(args[5].ptr(), false);
- has_clippath = render_clippath(clippath, clippath_trans);
- }
+ has_clippath = render_clippath(gc.clippath, gc.clippath_trans);
 
 Py::Tuple empty;
 image->flipud_out(empty);
@@ -855,7 +850,7 @@
 theRasterizer.add_path(rect2);
 agg::render_scanlines(theRasterizer, slineP8, ri);
 } else {
- set_clipbox(box_obj, rendererBase);
+ set_clipbox(gc.cliprect, rendererBase);
 rendererBase.blend_from(pixf, 0, (int)x, (int)(height-(y+image->rowsOut)));
 }
 
@@ -1026,15 +1021,13 @@
 _VERBOSE("RendererAgg::draw_path");
 args.verify_length(3, 4);
 
- Py::Object gc_obj = args[0];
- Py::Object path_obj = args[1];
+ GCAgg gc(args[0], dpi);
+ PathIterator path(args[1]);
 agg::trans_affine trans = py_to_agg_transformation_matrix(args[2].ptr());
 Py::Object face_obj;
 if (args.size() == 4)
 face_obj = args[3];
 
- PathIterator path(path_obj);
- GCAgg gc = GCAgg(gc_obj, dpi);
 facepair_t face = _get_rgba_face(face_obj, gc.alpha);
 
 theRasterizer.reset_clipping();
@@ -1275,32 +1268,29 @@
 Py::Object
 RendererAgg::draw_path_collection(const Py::Tuple& args) {
 _VERBOSE("RendererAgg::draw_path_collection");
- args.verify_length(14);
+ args.verify_length(12);
 
- //segments, trans, clipbox, colors, linewidths, antialiaseds
- agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[0].ptr());
- Py::Object		 cliprect	 = args[1];
- Py::Object		 clippath	 = args[2];
- agg::trans_affine clippath_trans = py_to_agg_transformation_matrix(args[3].ptr(), false);
- Py::SeqBase<Py::Object> paths		 = args[4];
- Py::SeqBase<Py::Object> transforms_obj = args[5];
- Py::Object offsets_obj = args[6];
- agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7].ptr());
- Py::Object facecolors_obj = args[8];
- Py::Object edgecolors_obj = args[9];
- Py::SeqBase<Py::Float> linewidths	 = args[10];
- Py::SeqBase<Py::Object> linestyles_obj = args[11];
- Py::SeqBase<Py::Int> antialiaseds	 = args[12];
+ GCAgg gc(args[0], dpi);
+ agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[1].ptr());
+ PathListGenerator paths(args[2]);
+ Py::SeqBase<Py::Object> transforms_obj = args[3];
+ Py::Object offsets_obj = args[4];
+ agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[5].ptr());
+ Py::Object facecolors_obj = args[6];
+ Py::Object edgecolors_obj = args[7];
+ Py::SeqBase<Py::Float> linewidths	 = args[8];
+ Py::SeqBase<Py::Object> linestyles_obj = args[9];
+ Py::SeqBase<Py::Int> antialiaseds	 = args[10];
 // We don't actually care about urls for Agg, so just ignore it.
- // Py::SeqBase<Py::Object> urls = args[13];
+ // Py::SeqBase<Py::Object> urls = args[11];
 PathListGenerator path_generator(paths);
 
 try {
 _draw_path_collection_generic<PathListGenerator, 0, 1>
 (master_transform,
- cliprect,
- clippath,
- clippath_trans,
+ gc.cliprect,
+ gc.clippath,
+ gc.clippath_trans,
 path_generator,
 transforms_obj,
 offsets_obj,
@@ -1390,22 +1380,20 @@
 Py::Object
 RendererAgg::draw_quad_mesh(const Py::Tuple& args) {
 _VERBOSE("RendererAgg::draw_quad_mesh");
- args.verify_length(12);
+ args.verify_length(10);
 
 
 //segments, trans, clipbox, colors, linewidths, antialiaseds
- agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[0].ptr());
- Py::Object		 cliprect	 = args[1];
- Py::Object		 clippath	 = args[2];
- agg::trans_affine clippath_trans = py_to_agg_transformation_matrix(args[3].ptr(), false);
- size_t mesh_width = Py::Int(args[4]);
- size_t mesh_height = Py::Int(args[5]);
- PyObject* coordinates	 = args[6].ptr();
- Py::Object offsets_obj = args[7];
- agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[8].ptr());
- Py::Object facecolors_obj = args[9];
- bool antialiased	 = (bool)Py::Int(args[10]);
- bool showedges = (bool)Py::Int(args[11]);
+ GCAgg gc(args[0], dpi);
+ agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[1].ptr());
+ size_t mesh_width = Py::Int(args[2]);
+ size_t mesh_height = Py::Int(args[3]);
+ PyObject* coordinates	 = args[4].ptr();
+ Py::Object offsets_obj = args[5];
+ agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[6].ptr());
+ Py::Object facecolors_obj = args[7];
+ bool antialiased	 = (bool)Py::Int(args[8]);
+ bool showedges = (bool)Py::Int(args[9]);
 bool free_edgecolors = false;
 
 QuadMeshGenerator path_generator(mesh_width, mesh_height, coordinates);
@@ -1437,9 +1425,9 @@
 try {
 _draw_path_collection_generic<QuadMeshGenerator, 0, 0>
 (master_transform,
- cliprect,
- clippath,
- clippath_trans,
+ gc.cliprect,
+ gc.clippath,
+ gc.clippath_trans,
 path_generator,
 transforms_obj,
 offsets_obj,
@@ -1467,6 +1455,73 @@
 }
 
 Py::Object
+RendererAgg::draw_gouraud_triangle(const Py::Tuple& args) {
+ _VERBOSE("RendererAgg::draw_quad_mesh");
+ args.verify_length(4);
+
+ typedef agg::rgba8 color_t;
+ typedef agg::span_gouraud_rgba<color_t> span_gen_t;
+ typedef agg::span_allocator<color_t> span_alloc_t;
+
+ //segments, trans, clipbox, colors, linewidths, antialiaseds
+ GCAgg gc(args[0], dpi);
+ Py::Object points_obj = args[1];
+ Py::Object colors_obj = args[2];
+ agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[3].ptr());
+
+ PyArrayObject* points = (PyArrayObject*)PyArray_ContiguousFromAny
+ (points_obj.ptr(), PyArray_DOUBLE, 2, 2);
+ if (!points ||
+ PyArray_DIM(points, 0) != 3 || PyArray_DIM(points, 1) != 2)
+ throw Py::ValueError("points must be a 3x2 numpy array");
+
+ PyArrayObject* colors = (PyArrayObject*)PyArray_ContiguousFromAny
+ (colors_obj.ptr(), PyArray_DOUBLE, 2, 2);
+ if (!colors ||
+ PyArray_DIM(colors, 0) != 3 || PyArray_DIM(colors, 1) != 4)
+ throw Py::ValueError("colors must be a 3x4 numpy array");
+
+ try {
+ double* opoints = (double*)PyArray_DATA(points);
+ double* c = (double*)PyArray_DATA(colors);
+ double tpoints[6];
+
+ for (int i = 0; i < 6; i += 2) {
+ tpoints[i] = opoints[i];
+ tpoints[i+1] = opoints[i+1];
+ master_transform.transform(&tpoints[i], &tpoints[i+1]);
+ }
+
+ span_alloc_t span_alloc;
+ span_gen_t span_gen;
+
+ span_gen.colors(
+ agg::rgba(c[0], c[1], c[2], c[3]),
+ agg::rgba(c[4], c[5], c[6], c[7]),
+ agg::rgba(c[8], c[9], c[10], c[11]));
+ span_gen.triangle(
+ tpoints[0], tpoints[1],
+ tpoints[2], tpoints[3],
+ tpoints[4], tpoints[5],
+ 1.0);
+
+ theRasterizer.add_path(span_gen);
+ agg::render_scanlines_aa(
+ theRasterizer, slineP8, rendererBase, span_alloc, span_gen);
+ } catch (...) {
+ Py_DECREF(points);
+ Py_DECREF(colors);
+
+ throw;
+ }
+
+ Py_DECREF(points);
+ Py_DECREF(colors);
+
+ return Py::Object();
+}
+
+Py::Object
 RendererAgg::write_rgba(const Py::Tuple& args) {
 _VERBOSE("RendererAgg::write_rgba");
 
@@ -1802,15 +1857,17 @@
 add_varargs_method("draw_path", &RendererAgg::draw_path,
 		 "draw_path(gc, path, transform, rgbFace)\n");
 add_varargs_method("draw_path_collection", &RendererAgg::draw_path_collection,
-		 "draw_path_collection(master_transform, cliprect, clippath, clippath_trans, paths, transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds)\n");
+		 "draw_path_collection(gc, master_transform, paths, transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds)\n");
 add_varargs_method("draw_quad_mesh", &RendererAgg::draw_quad_mesh,
-		 "draw_quad_mesh(master_transform, cliprect, clippath, clippath_trans, meshWidth, meshHeight, coordinates, offsets, offsetTrans, facecolors, antialiaseds, showedges)\n");
+		 "draw_quad_mesh(gc, master_transform, meshWidth, meshHeight, coordinates, offsets, offsetTrans, facecolors, antialiaseds, showedges)\n");
+ add_varargs_method("draw_gouraud_triangle", &RendererAgg::draw_gouraud_triangle,
+		 "draw_gouraud_triangle(gc, points, colors, master_transform)\n");
 add_varargs_method("draw_markers", &RendererAgg::draw_markers,
 		 "draw_markers(gc, marker_path, marker_trans, path, rgbFace)\n");
 add_varargs_method("draw_text_image", &RendererAgg::draw_text_image,
 		 "draw_text_image(font_image, x, y, r, g, b, a)\n");
 add_varargs_method("draw_image", &RendererAgg::draw_image,
-		 "draw_image(x, y, im)");
+		 "draw_image(gc, x, y, im)");
 add_varargs_method("write_rgba", &RendererAgg::write_rgba,
 		 "write_rgba(fname)");
 add_varargs_method("tostring_rgb", &RendererAgg::tostring_rgb,
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h	2009年08月07日 15:40:56 UTC (rev 7416)
+++ trunk/matplotlib/src/_backend_agg.h	2009年08月07日 17:02:28 UTC (rev 7417)
@@ -164,8 +164,8 @@
 Py::Object draw_path(const Py::Tuple & args);
 Py::Object draw_path_collection(const Py::Tuple & args);
 Py::Object draw_quad_mesh(const Py::Tuple& args);
+ Py::Object draw_gouraud_triangle(const Py::Tuple& args);
 
-
 Py::Object write_rgba(const Py::Tuple & args);
 Py::Object tostring_rgb(const Py::Tuple & args);
 Py::Object tostring_argb(const Py::Tuple & args);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年08月07日 15:41:04
Revision: 7416
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7416&view=rev
Author: jdh2358
Date: 2009年08月07日 15:40:56 +0000 (2009年8月07日)
Log Message:
-----------
don't fail on window icon load
Modified Paths:
--------------
 branches/v0_99_maint/doc/devel/coding_guide.rst
 branches/v0_99_maint/lib/matplotlib/backends/backend_gtk.py
Modified: branches/v0_99_maint/doc/devel/coding_guide.rst
===================================================================
--- branches/v0_99_maint/doc/devel/coding_guide.rst	2009年08月07日 14:26:35 UTC (rev 7415)
+++ branches/v0_99_maint/doc/devel/coding_guide.rst	2009年08月07日 15:40:56 UTC (rev 7416)
@@ -24,17 +24,11 @@
 svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/\
 matplotlib mpl --username=youruser --password=yourpass
 
-Branch checkouts, eg the maintenance branch::
+Branch checkouts, eg the release branch::
 
- svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/\
- v0_91_maint mpl91 --username=youruser --password=yourpass
+ svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint mpl99
 
-The current release of the trunk is in the 0.98.5 maintenance branch::
 
- svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/\
- v0_98_5_maint mpl98.5 --username=youruser --password=yourpass
-
-
 Committing changes
 ------------------
 
@@ -64,11 +58,10 @@
 :file:`MANIFEST.in`. This file determines what goes into the source
 distribution of the mpl build.
 
-* Keep the maintenance branch (0.91) the latest release branch (eg
- 0.98.4) and trunk in sync where it makes sense. If there is a bug
- on both that needs fixing, use `svnmerge.py
- <http://www.orcaware.com/svn/wiki/Svnmerge.py>`_ to keep them in
- sync. See :ref:`svn-merge` below.
+* Keep the release branch (eg 0.90 and trunk in sync where it makes
+ sense. If there is a bug on both that needs fixing, use
+ `svnmerge.py <http://www.orcaware.com/svn/wiki/Svnmerge.py>`_ to
+ keep them in sync. See :ref:`svn-merge` below.
 
 .. _svn-merge:
 
@@ -96,7 +89,7 @@
 svnmerge.py merge -S BRANCHNAME
 
 Where BRANCHNAME is the name of the branch to merge *from*,
- e.g. v0_98_5_maint.
+ e.g. v0_99_maint.
 
 If you wish to merge only specific revisions (in an unusual
 situation), do::
Modified: branches/v0_99_maint/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/backends/backend_gtk.py	2009年08月07日 14:26:35 UTC (rev 7415)
+++ branches/v0_99_maint/lib/matplotlib/backends/backend_gtk.py	2009年08月07日 15:40:56 UTC (rev 7416)
@@ -440,8 +440,15 @@
 self.window = gtk.Window()
 self.window.set_title("Figure %d" % num)
 if (window_icon):
- self.window.set_icon_from_file(window_icon)
-
+ try:
+ self.window.set_icon_from_file(window_icon)
+ except:
+ # some versions of gtk throw a glib.GError but not
+ # all, so I am not sure how to catch it. I am unhappy
+ # diong a blanket catch here, but an not sure what a
+ # better way is - JDH
+ verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])
+ 
 self.vbox = gtk.VBox()
 self.window.add(self.vbox)
 self.vbox.show()
@@ -666,7 +673,11 @@
 
 window = gtk.Window()
 if (window_icon):
- window.set_icon_from_file(window_icon)
+ try: window.set_icon_from_file(window_icon)
+ except:
+ # we presumably already logged a message on the
+ # failure of the main plot, don't keep reporting
+ pass
 window.set_title("Subplot Configuration Tool")
 window.set_default_size(w, h)
 vbox = gtk.VBox()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7415
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7415&view=rev
Author: jswhit
Date: 2009年08月07日 14:26:35 +0000 (2009年8月07日)
Log Message:
-----------
change example in docstrings to use np.loadtxt instead of mlab.load
Modified Paths:
--------------
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2009年08月07日 10:15:04 UTC (rev 7414)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2009年08月07日 14:26:35 UTC (rev 7415)
@@ -379,11 +379,10 @@
 >>> from mpl_toolkits.basemap import Basemap
 >>> import numpy as np
 >>> import matplotlib.pyplot as plt
- >>> import matplotlib.mlab as mlab
 >>> # read in topo data (on a regular lat/lon grid)
- >>> etopo = mlab.load('etopo20data.gz')
- >>> lons = mlab.load('etopo20lons.gz')
- >>> lats = mlab.load('etopo20lats.gz')
+ >>> etopo = np.loadtxt('etopo20data.gz')
+ >>> lons = np.loadtxt('etopo20lons.gz')
+ >>> lats = np.loadtxt('etopo20lats.gz')
 >>> # create Basemap instance for Robinson projection.
 >>> m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]))
 >>> # compute map projection coordinates for lat/lon grid.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年08月07日 10:15:11
Revision: 7414
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7414&view=rev
Author: jdh2358
Date: 2009年08月07日 10:15:04 +0000 (2009年8月07日)
Log Message:
-----------
some doc fixes
Modified Paths:
--------------
 branches/v0_99_maint/doc/users/annotations.rst
 branches/v0_99_maint/doc/users/artists.rst
 branches/v0_99_maint/doc/users/event_handling.rst
 branches/v0_99_maint/doc/users/pyplot_tutorial.rst
Modified: branches/v0_99_maint/doc/users/annotations.rst
===================================================================
--- branches/v0_99_maint/doc/users/annotations.rst	2009年08月07日 00:42:20 UTC (rev 7413)
+++ branches/v0_99_maint/doc/users/annotations.rst	2009年08月07日 10:15:04 UTC (rev 7414)
@@ -78,6 +78,4 @@
 .. plot:: pyplots/annotation_polar.py
 :include-source:
 
-See the `annotations demo
-<http://matplotlib.sf.net/examples/pylab_examples/annotation_demo.py>`_ for more
-examples.
+For more on all the wild and wonderful things you can do with annotations, including fancy arrows, see :ref:`plotting-guide-annotation` and :ref:`pylab_examples-annotation_demo`.
Modified: branches/v0_99_maint/doc/users/artists.rst
===================================================================
--- branches/v0_99_maint/doc/users/artists.rst	2009年08月07日 00:42:20 UTC (rev 7413)
+++ branches/v0_99_maint/doc/users/artists.rst	2009年08月07日 10:15:04 UTC (rev 7414)
@@ -19,27 +19,7 @@
 and laying out the figure, text, and lines. The typical user will
 spend 95% of his time working with the ``Artists``.
 
-There are two types of ``Artists``: primitives and containers. The
-primitives represent the standard graphical objects we want to paint
-onto our canvas: :class:`~matplotlib.lines.Line2D`,
-:class:`~matplotlib.patches.Rectangle`,
-:class:`~matplotlib.text.Text`, :class:`~matplotlib.image.AxesImage`,
-etc., and the containers are places to put them
-(:class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axes.Axes` and
-:class:`~matplotlib.figure.Figure`). The standard use is to create a
-:class:`~matplotlib.figure.Figure` instance, use the ``Figure`` to
-create one or more :class:`~matplotlib.axes.Axes` or
-:class:`~matplotlib.axes.Subplot` instances, and use the ``Axes``
-instance helper methods to create the primitives. In the example
-below, we create a ``Figure`` instance using
-:func:`matplotlib.pyplot.figure`, which is a convenience method for
-instantiating ``Figure`` instances and connecting them with your user
-interface or drawing toolkit ``FigureCanvas``. As we will discuss
-below, this is not necessary, and you can work directly with
-PostScript, PDF Gtk+, or wxPython ``FigureCanvas`` instances. For
-example, instantiate your ``Figures`` directly and connect them
-yourselves, but since we are focusing here on the ``Artist`` API we'll let
-:mod:`~matplotlib.pyplot` handle some of those details for us::
+There are two types of ``Artists``: primitives and containers. The primitives represent the standard graphical objects we want to paint onto our canvas: :class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.patches.Rectangle`, :class:`~matplotlib.text.Text`, :class:`~matplotlib.image.AxesImage`, etc., and the containers are places to put them (:class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axes.Axes` and :class:`~matplotlib.figure.Figure`). The standard use is to create a :class:`~matplotlib.figure.Figure` instance, use the ``Figure`` to create one or more :class:`~matplotlib.axes.Axes` or :class:`~matplotlib.axes.Subplot` instances, and use the ``Axes`` instance helper methods to create the primitives. In the example below, we create a ``Figure`` instance using :func:`matplotlib.pyplot.figure`, which is a convenience method for instantiating ``Figure`` instances and connecting them with your user interface or drawing toolkit ``FigureCanvas``. As we will discuss below, this is not necessary -- you can work directly with PostScript, PDF Gtk+, or wxPython ``FigureCanvas`` instances, instantiate your ``Figures`` directly and connect them yourselves -- but since we are focusing here on the ``Artist`` API we'll let :mod:`~matplotlib.pyplot` handle some of those details for us::
 
 import matplotlib.pyplot as plt
 fig = plt.figure()
@@ -85,7 +65,7 @@
 <matplotlib.axes.Axes.lines>` list. In the interactive `ipython
 <http://ipython.scipy.org/>`_ session below, you can see that the
 ``Axes.lines`` list is length one and contains the same line that was
-returned by the ``line, = ax.plot(x, y, 'o')`` call:
+returned by the ``line, = ax.plot...`` call:
 
 .. sourcecode:: ipython
 
@@ -536,20 +516,7 @@
 :class:`~matplotlib.ticker.Formatter` instances which control where
 the ticks are placed and how they are represented as strings.
 
-Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label`
-attribute (this is what the :mod:`~matplotlib.pylab` calls to
-:func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`
-set) as well as a list of major and minor ticks. The ticks are
-:class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick`
-instances, which contain the actual line and text primitives that
-render the ticks and ticklabels. Because the ticks are dynamically
-created as needed (eg. when panning and zooming), you should access
-the lists of major and minor ticks through their accessor methods
-:meth:`~matplotlib.axis.Axis.get_major_ticks` and
-:meth:`~matplotlib.axis.Axis.get_minor_ticks`. Although the ticks
-contain all the primitives and will be covered below, the ``Axis`` methods
-contain accessor methods to return the tick lines, tick labels, tick
-locations etc.:
+Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute (this is what :mod:`~matplotlib.pylab` modifies in calls to :func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well as a list of major and minor ticks. The ticks are :class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances, which contain the actual line and text primitives that render the ticks and ticklabels. Because the ticks are dynamically created as needed (eg. when panning and zooming), you should access the lists of major and minor ticks through their accessor methods :meth:`~matplotlib.axis.Axis.get_major_ticks` and :meth:`~matplotlib.axis.Axis.get_minor_ticks`. Although the ticks contain all the primitives and will be covered below, the ``Axis`` methods contain accessor methods to return the tick lines, tick labels, tick locations etc.:
 
 .. sourcecode:: ipython
 
@@ -636,7 +603,7 @@
 label2On boolean which determines whether to draw tick label
 ============== ==========================================================
 
-Here is an example which sets the formatter for the upper ticks with
+Here is an example which sets the formatter for the right side ticks with
 dollar signs and colors them green on the right side of the yaxis
 
 .. plot:: pyplots/dollar_ticks.py
Modified: branches/v0_99_maint/doc/users/event_handling.rst
===================================================================
--- branches/v0_99_maint/doc/users/event_handling.rst	2009年08月07日 00:42:20 UTC (rev 7413)
+++ branches/v0_99_maint/doc/users/event_handling.rst	2009年08月07日 10:15:04 UTC (rev 7414)
@@ -1,555 +1,555 @@
-.. _event-handling-tutorial:
-
-**************************
-Event handling and picking
-**************************
-
-matplotlib works with 5 user interface toolkits (wxpython, tkinter,
-qt, gtk and fltk) and in order to support features like interactive
-panning and zooming of figures, it is helpful to the developers to
-have an API for interacting with the figure via key presses and mouse
-movements that is "GUI neutral" so we don't have to repeat a lot of
-code across the different user interfaces. Although the event
-handling API is GUI neutral, it is based on the GTK model, which was
-the first user interface matplotlib supported. The events that are
-triggered are also a bit richer vis-a-vis matplotlib than standard GUI
-events, including information like which :class:`matplotlib.axes.Axes`
-the event occurred in. The events also understand the matplotlib
-coordinate system, and report event locations in both pixel and data
-coordinates.
-
-.. _event-connections:
-
-Event connections
-=================
-
-To receive events, you need to write a callback function and then
-connect your function to the event manager, which is part of the
-:class:`~matplotlib.backend_bases.FigureCanvasBase`. Here is a simple
-example that prints the location of the mouse click and which button
-was pressed::
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
- ax.plot(np.random.rand(10))
-
- def onclick(event):
- print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
- event.button, event.x, event.y, event.xdata, event.ydata)
-
- cid = fig.canvas.mpl_connect('button_press_event', onclick)
-
-The ``FigureCanvas`` method
-:meth:`~matplotlib.backend_bases.FigureCanvasBase.mpl_connect` returns
-a connection id which is simply an integer. When you want to
-disconnect the callback, just call::
-
- fig.canvas.mpl_disconnect(cid)
-
-Here are the events that you can connect to, the class instances that
-are sent back to you when the event occurs, and the event descriptions
-
-
-======================= ======================================================================================
-Event name Class and description
-======================= ======================================================================================
-'button_press_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse button is pressed
-'button_release_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse button is released
-'draw_event' :class:`~matplotlib.backend_bases.DrawEvent` - canvas draw
-'key_press_event' :class:`~matplotlib.backend_bases.KeyEvent` - key is pressed
-'key_release_event' :class:`~matplotlib.backend_bases.KeyEvent` - key is released
-'motion_notify_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse motion
-'pick_event' :class:`~matplotlib.backend_bases.PickEvent` - an object in the canvas is selected
-'resize_event' :class:`~matplotlib.backend_bases.ResizeEvent` - figure canvas is resized
-'scroll_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse scroll wheel is rolled
-'figure_enter_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse enters a new figure
-'figure_leave_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse leaves a figure
-'axes_enter_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse enters a new axes
-'axes_leave_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse leaves an axes
-======================= ======================================================================================
-
-.. _event-attributes:
-
-Event attributes
-================
-
-All matplotlib events inherit from the base class
-:class:`matplotlib.backend_bases.Event`, which store the attributes:
-
- ``name``
-	the event name
-
- ``canvas``
-	the FigureCanvas instance generating the event
-
- ``guiEvent``
-	the GUI event that triggered the matplotlib event
-
-
-The most common events that are the bread and butter of event handling
-are key press/release events and mouse press/release and movement
-events. The :class:`~matplotlib.backend_bases.KeyEvent` and
-:class:`~matplotlib.backend_bases.MouseEvent` classes that handle
-these events are both derived from the LocationEvent, which has the
-following attributes
-
- ``x``
- x position - pixels from left of canvas
-
- ``y``
- y position - pixels from bottom of canvas
-
- ``inaxes``
- the :class:`~matplotlib.axes.Axes` instance if mouse is over axes
-
- ``xdata``
- x coord of mouse in data coords
-
- ``ydata``
- y coord of mouse in data coords
-
-Let's look a simple example of a canvas, where a simple line segment
-is created every time a mouse is pressed::
-
- class LineBuilder:
- def __init__(self, line):
- self.line = line
- self.xs = list(line.get_xdata())
- self.ys = list(line.get_ydata())
- self.cid = line.figure.canvas.mpl_connect('button_press_event', self)
-
- def __call__(self, event):
- print 'click', event
- if event.inaxes!=self.line.axes: return
- self.xs.append(event.xdata)
- self.ys.append(event.ydata)
- self.line.set_data(self.xs, self.ys)
- self.line.figure.canvas.draw()
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
- ax.set_title('click to build line segments')
- line, = ax.plot([0], [0]) # empty line
- linebuilder = LineBuilder(line)
-
-
-
-The :class:`~matplotlib.backend_bases.MouseEvent` that we just used is a
-:class:`~matplotlib.backend_bases.LocationEvent`, so we have access to
-the data and pixel coordinates in event.x and event.xdata. In
-addition to the ``LocationEvent`` attributes, it has
-
- ``button``
- button pressed None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events)
-
- ``key``
- the key pressed: None, chr(range(255), 'shift', 'win', or 'control'
-
-Draggable rectangle exercise
-----------------------------
-
-Write draggable rectangle class that is initialized with a
-:class:`~matplotlib.patches.Rectangle` instance but will move its x,y
-location when dragged. Hint: you will need to store the orginal
-``xy`` location of the rectangle which is stored as rect.xy and
-connect to the press, motion and release mouse events. When the mouse
-is pressed, check to see if the click occurs over your rectangle (see
-:meth:`matplotlib.patches.Rectangle.contains`) and if it does, store
-the rectangle xy and the location of the mouse click in data coords.
-In the motion event callback, compute the deltax and deltay of the
-mouse movement, and add those deltas to the origin of the rectangle
-you stored. The redraw the figure. On the button release event, just
-reset all the button press data you stored as None.
-
-Here is the solution::
-
- import numpy as np
- import matplotlib.pyplot as plt
-
- class DraggableRectangle:
- def __init__(self, rect):
- self.rect = rect
- self.press = None
-
- def connect(self):
- 'connect to all the events we need'
- self.cidpress = self.rect.figure.canvas.mpl_connect(
- 'button_press_event', self.on_press)
- self.cidrelease = self.rect.figure.canvas.mpl_connect(
- 'button_release_event', self.on_release)
- self.cidmotion = self.rect.figure.canvas.mpl_connect(
- 'motion_notify_event', self.on_motion)
-
- def on_press(self, event):
- 'on button press we will see if the mouse is over us and store some data'
- if event.inaxes != self.rect.axes: return
-
- contains, attrd = self.rect.contains(event)
- if not contains: return
- print 'event contains', self.rect.xy
- x0, y0 = self.rect.xy
- self.press = x0, y0, event.xdata, event.ydata
-
- def on_motion(self, event):
- 'on motion we will move the rect if the mouse is over us'
- if self.press is None: return
- if event.inaxes != self.rect.axes: return
- x0, y0, xpress, ypress = self.press
- dx = event.xdata - xpress
- dy = event.ydata - ypress
- #print 'x0=%f, xpress=%f, event.xdata=%f, dx=%f, x0+dx=%f'%(x0, xpress, event.xdata, dx, x0+dx)
- self.rect.set_x(x0+dx)
- self.rect.set_y(y0+dy)
-
- self.rect.figure.canvas.draw()
-
-
- def on_release(self, event):
- 'on release we reset the press data'
- self.press = None
- self.rect.figure.canvas.draw()
-
- def disconnect(self):
- 'disconnect all the stored connection ids'
- self.rect.figure.canvas.mpl_disconnect(self.cidpress)
- self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
- self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
- rects = ax.bar(range(10), 20*np.random.rand(10))
- drs = []
- for rect in rects:
- dr = DraggableRectangle(rect)
- dr.connect()
- drs.append(dr)
-
- plt.show()
-
-
-**Extra credit**: use the animation blit techniques discussed in the
-`animations recipe
-<http://www.scipy.org/Cookbook/Matplotlib/Animations>`_ to make the
-animated drawing faster and smoother.
-
-Extra credit solution::
-
- # draggable rectangle with the animation blit techniques; see
- # http://www.scipy.org/Cookbook/Matplotlib/Animations
- import numpy as np
- import matplotlib.pyplot as plt
-
- class DraggableRectangle:
- lock = None # only one can be animated at a time
- def __init__(self, rect):
- self.rect = rect
- self.press = None
- self.background = None
-
- def connect(self):
- 'connect to all the events we need'
- self.cidpress = self.rect.figure.canvas.mpl_connect(
- 'button_press_event', self.on_press)
- self.cidrelease = self.rect.figure.canvas.mpl_connect(
- 'button_release_event', self.on_release)
- self.cidmotion = self.rect.figure.canvas.mpl_connect(
- 'motion_notify_event', self.on_motion)
-
- def on_press(self, event):
- 'on button press we will see if the mouse is over us and store some data'
- if event.inaxes != self.rect.axes: return
- if DraggableRectangle.lock is not None: return
- contains, attrd = self.rect.contains(event)
- if not contains: return
- print 'event contains', self.rect.xy
- x0, y0 = self.rect.xy
- self.press = x0, y0, event.xdata, event.ydata
- DraggableRectangle.lock = self
-
- # draw everything but the selected rectangle and store the pixel buffer
- canvas = self.rect.figure.canvas
- axes = self.rect.axes
- self.rect.set_animated(True)
- canvas.draw()
- self.background = canvas.copy_from_bbox(self.rect.axes.bbox)
-
- # now redraw just the rectangle
- axes.draw_artist(self.rect)
-
- # and blit just the redrawn area
- canvas.blit(axes.bbox)
-
- def on_motion(self, event):
- 'on motion we will move the rect if the mouse is over us'
- if DraggableRectangle.lock is not self:
- return
- if event.inaxes != self.rect.axes: return
- x0, y0, xpress, ypress = self.press
- dx = event.xdata - xpress
- dy = event.ydata - ypress
- self.rect.set_x(x0+dx)
- self.rect.set_y(y0+dy)
-
- canvas = self.rect.figure.canvas
- axes = self.rect.axes
- # restore the background region
- canvas.restore_region(self.background)
-
- # redraw just the current rectangle
- axes.draw_artist(self.rect)
-
- # blit just the redrawn area
- canvas.blit(axes.bbox)
-
- def on_release(self, event):
- 'on release we reset the press data'
- if DraggableRectangle.lock is not self:
- return
-
- self.press = None
- DraggableRectangle.lock = None
-
- # turn off the rect animation property and reset the background
- self.rect.set_animated(False)
- self.background = None
-
- # redraw the full figure
- self.rect.figure.canvas.draw()
-
- def disconnect(self):
- 'disconnect all the stored connection ids'
- self.rect.figure.canvas.mpl_disconnect(self.cidpress)
- self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
- self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
- rects = ax.bar(range(10), 20*np.random.rand(10))
- drs = []
- for rect in rects:
- dr = DraggableRectangle(rect)
- dr.connect()
- drs.append(dr)
-
- plt.show()
-
-
-.. _enter-leave-events:
-
-Mouse enter and leave
-======================
-
-If you want to be notified when the mouse enters or leaves a figure or
-axes, you can connect to the figure/axes enter/leave events. Here is
-a simple example that changes the colors of the axes and figure
-background that the mouse is over::
-
- """
- Illustrate the figure and axes enter and leave events by changing the
- frame colors on enter and leave
- """
- import matplotlib.pyplot as plt
-
- def enter_axes(event):
- print 'enter_axes', event.inaxes
- event.inaxes.patch.set_facecolor('yellow')
- event.canvas.draw()
-
- def leave_axes(event):
- print 'leave_axes', event.inaxes
- event.inaxes.patch.set_facecolor('white')
- event.canvas.draw()
-
- def enter_figure(event):
- print 'enter_figure', event.canvas.figure
- event.canvas.figure.patch.set_facecolor('red')
- event.canvas.draw()
-
- def leave_figure(event):
- print 'leave_figure', event.canvas.figure
- event.canvas.figure.patch.set_facecolor('grey')
- event.canvas.draw()
-
- fig1 = plt.figure()
- fig1.suptitle('mouse hover over figure or axes to trigger events')
- ax1 = fig1.add_subplot(211)
- ax2 = fig1.add_subplot(212)
-
- fig1.canvas.mpl_connect('figure_enter_event', enter_figure)
- fig1.canvas.mpl_connect('figure_leave_event', leave_figure)
- fig1.canvas.mpl_connect('axes_enter_event', enter_axes)
- fig1.canvas.mpl_connect('axes_leave_event', leave_axes)
-
- fig2 = plt.figure()
- fig2.suptitle('mouse hover over figure or axes to trigger events')
- ax1 = fig2.add_subplot(211)
- ax2 = fig2.add_subplot(212)
-
- fig2.canvas.mpl_connect('figure_enter_event', enter_figure)
- fig2.canvas.mpl_connect('figure_leave_event', leave_figure)
- fig2.canvas.mpl_connect('axes_enter_event', enter_axes)
- fig2.canvas.mpl_connect('axes_leave_event', leave_axes)
-
- plt.show()
-
-
-
-.. _object-picking:
-
-Object picking
-==============
-
-You can enable picking by setting the ``picker`` property of an
-:class:`~matplotlib.artist.Artist` (eg a matplotlib
-:class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.text.Text`,
-:class:`~matplotlib.patches.Patch`, :class:`~matplotlib.patches.Polygon`,
-:class:`~matplotlib.patches.AxesImage`, etc...)
-
-There are a variety of meanings of the ``picker`` property:
-
- ``None``
-	picking is disabled for this artist (default)
-
- ``boolean``
-	if True then picking will be enabled and the artist will fire a
-	pick event if the mouse event is over the artist
-
- ``float``
-	if picker is a number it is interpreted as an epsilon tolerance in
-	points and the the artist will fire off an event if its data is
-	within epsilon of the mouse event. For some artists like lines
-	and patch collections, the artist may provide additional data to
-	the pick event that is generated, eg the indices of the data
-	within epsilon of the pick event.
-
- ``function``
-	if picker is callable, it is a user supplied function which
-	determines whether the artist is hit by the mouse event. The
-	signature is ``hit, props = picker(artist, mouseevent)`` to
-	determine the hit test. If the mouse event is over the artist,
-	return ``hit=True`` and props is a dictionary of properties you
-	want added to the :class:`~matplotlib.backend_bases.PickEvent`
-	attributes
-
-
-After you have enabled an artist for picking by setting the ``picker``
-property, you need to connect to the figure canvas pick_event to get
-pick callbacks on mouse press events. Eg::
-
- def pick_handler(event):
- mouseevent = event.mouseevent
- artist = event.artist
- # now do something with this...
-
-
-The :class:`~matplotlib.backend_bases.PickEvent` which is passed to
-your callback is always fired with two attributes:
-
- ``mouseevent`` the mouse event that generate the pick event. The
-	mouse event in turn has attributes like ``x`` and ``y`` (the
-	coords in display space, eg pixels from left, bottom) and xdata,
-	ydata (the coords in data space). Additionally, you can get
-	information about which buttons were pressed, which keys were
-	pressed, which :class:`~matplotlib.axes.Axes` the mouse is over,
-	etc. See :class:`matplotlib.backend_bases.MouseEvent` for
-	details.
-
- ``artist``
-	the :class:`~matplotlib.artist.Artist` that generated the pick
-	event.
-
-Additionally, certain artists like :class:`~matplotlib.lines.Line2D`
-and :class:`~matplotlib.collections.PatchCollection` may attach
-additional meta data like the indices into the data that meet the
-picker criteria (eg all the points in the line that are within the
-specified epsilon tolerance)
-
-Simple picking example
-----------------------
-
-In the example below, we set the line picker property to a scalar, so
-it represents a tolerance in points (72 points per inch). The onpick
-callback function will be called when the pick event it within the
-tolerance distance from the line, and has the indices of the data
-vertices that are within the pick distance tolerance. Our onpick
-callback function simply prints the data that are under the pick
-location. Different matplotlib Artists can attach different data to
-the PickEvent. For example, ``Line2D`` attaches the ind property,
-which are the indices into the line data under the pick point. See
-:meth:`~matplotlib.lines.Line2D.pick` for details on the ``PickEvent``
-properties of the line. Here is the code::
-
- import numpy as np
- import matplotlib.pyplot as plt
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
- ax.set_title('click on points')
-
- line, = ax.plot(np.random.rand(100), 'o', picker=5) # 5 points tolerance
-
- def onpick(event):
- thisline = event.artist
- xdata = thisline.get_xdata()
- ydata = thisline.get_ydata()
- ind = event.ind
- print 'onpick points:', zip(xdata[ind], ydata[ind])
-
- fig.canvas.mpl_connect('pick_event', onpick)
-
- plt.show()
-
-
-Picking exercise
-----------------
-
-Create a data set of 100 arrays of 1000 Gaussian random numbers and
-compute the sample mean and standard deviation of each of them (hint:
-numpy arrays have a mean and std method) and make a xy marker plot of
-the 100 means vs the 100 standard deviations. Connect the line
-created by the plot command to the pick event, and plot the original
-time series of the data that generated the clicked on points. If more
-than one point is within the tolerance of the clicked on point, you
-can use multiple subplots to plot the multiple time series.
-
-Exercise solution::
-
- """
- compute the mean and stddev of 100 data sets and plot mean vs stddev.
- When you click on one of the mu, sigma points, plot the raw data from
- the dataset that generated the mean and stddev
- """
- import numpy as np
- import matplotlib.pyplot as plt
-
- X = np.random.rand(100, 1000)
- xs = np.mean(X, axis=1)
- ys = np.std(X, axis=1)
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
- ax.set_title('click on point to plot time series')
- line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
-
-
- def onpick(event):
-
- if event.artist!=line: return True
-
- N = len(event.ind)
- if not N: return True
-
-
- figi = plt.figure()
- for subplotnum, dataind in enumerate(event.ind):
- ax = figi.add_subplot(N,1,subplotnum+1)
- ax.plot(X[dataind])
- ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
- transform=ax.transAxes, va='top')
- ax.set_ylim(-0.5, 1.5)
- figi.show()
- return True
-
- fig.canvas.mpl_connect('pick_event', onpick)
-
+.. _event-handling-tutorial:
+
+**************************
+Event handling and picking
+**************************
+
+matplotlib works with 6 user interface toolkits (wxpython, tkinter,
+qt, gtk, fltk abd macosx) and in order to support features like interactive
+panning and zooming of figures, it is helpful to the developers to
+have an API for interacting with the figure via key presses and mouse
+movements that is "GUI neutral" so we don't have to repeat a lot of
+code across the different user interfaces. Although the event
+handling API is GUI neutral, it is based on the GTK model, which was
+the first user interface matplotlib supported. The events that are
+triggered are also a bit richer vis-a-vis matplotlib than standard GUI
+events, including information like which :class:`matplotlib.axes.Axes`
+the event occurred in. The events also understand the matplotlib
+coordinate system, and report event locations in both pixel and data
+coordinates.
+
+.. _event-connections:
+
+Event connections
+=================
+
+To receive events, you need to write a callback function and then
+connect your function to the event manager, which is part of the
+:class:`~matplotlib.backend_bases.FigureCanvasBase`. Here is a simple
+example that prints the location of the mouse click and which button
+was pressed::
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.plot(np.random.rand(10))
+
+ def onclick(event):
+ print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
+ event.button, event.x, event.y, event.xdata, event.ydata)
+
+ cid = fig.canvas.mpl_connect('button_press_event', onclick)
+
+The ``FigureCanvas`` method
+:meth:`~matplotlib.backend_bases.FigureCanvasBase.mpl_connect` returns
+a connection id which is simply an integer. When you want to
+disconnect the callback, just call::
+
+ fig.canvas.mpl_disconnect(cid)
+
+Here are the events that you can connect to, the class instances that
+are sent back to you when the event occurs, and the event descriptions
+
+
+======================= ======================================================================================
+Event name Class and description
+======================= ======================================================================================
+'button_press_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse button is pressed
+'button_release_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse button is released
+'draw_event' :class:`~matplotlib.backend_bases.DrawEvent` - canvas draw
+'key_press_event' :class:`~matplotlib.backend_bases.KeyEvent` - key is pressed
+'key_release_event' :class:`~matplotlib.backend_bases.KeyEvent` - key is released
+'motion_notify_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse motion
+'pick_event' :class:`~matplotlib.backend_bases.PickEvent` - an object in the canvas is selected
+'resize_event' :class:`~matplotlib.backend_bases.ResizeEvent` - figure canvas is resized
+'scroll_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse scroll wheel is rolled
+'figure_enter_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse enters a new figure
+'figure_leave_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse leaves a figure
+'axes_enter_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse enters a new axes
+'axes_leave_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse leaves an axes
+======================= ======================================================================================
+
+.. _event-attributes:
+
+Event attributes
+================
+
+All matplotlib events inherit from the base class
+:class:`matplotlib.backend_bases.Event`, which store the attributes:
+
+ ``name``
+	the event name
+
+ ``canvas``
+	the FigureCanvas instance generating the event
+
+ ``guiEvent``
+	the GUI event that triggered the matplotlib event
+
+
+The most common events that are the bread and butter of event handling
+are key press/release events and mouse press/release and movement
+events. The :class:`~matplotlib.backend_bases.KeyEvent` and
+:class:`~matplotlib.backend_bases.MouseEvent` classes that handle
+these events are both derived from the LocationEvent, which has the
+following attributes
+
+ ``x``
+ x position - pixels from left of canvas
+
+ ``y``
+ y position - pixels from bottom of canvas
+
+ ``inaxes``
+ the :class:`~matplotlib.axes.Axes` instance if mouse is over axes
+
+ ``xdata``
+ x coord of mouse in data coords
+
+ ``ydata``
+ y coord of mouse in data coords
+
+Let's look a simple example of a canvas, where a simple line segment
+is created every time a mouse is pressed::
+
+ class LineBuilder:
+ def __init__(self, line):
+ self.line = line
+ self.xs = list(line.get_xdata())
+ self.ys = list(line.get_ydata())
+ self.cid = line.figure.canvas.mpl_connect('button_press_event', self)
+
+ def __call__(self, event):
+ print 'click', event
+ if event.inaxes!=self.line.axes: return
+ self.xs.append(event.xdata)
+ self.ys.append(event.ydata)
+ self.line.set_data(self.xs, self.ys)
+ self.line.figure.canvas.draw()
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.set_title('click to build line segments')
+ line, = ax.plot([0], [0]) # empty line
+ linebuilder = LineBuilder(line)
+
+
+
+The :class:`~matplotlib.backend_bases.MouseEvent` that we just used is a
+:class:`~matplotlib.backend_bases.LocationEvent`, so we have access to
+the data and pixel coordinates in event.x and event.xdata. In
+addition to the ``LocationEvent`` attributes, it has
+
+ ``button``
+ button pressed None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events)
+
+ ``key``
+ the key pressed: None, any character, 'shift', 'win', or 'control'
+
+Draggable rectangle exercise
+----------------------------
+
+Write draggable rectangle class that is initialized with a
+:class:`~matplotlib.patches.Rectangle` instance but will move its x,y
+location when dragged. Hint: you will need to store the orginal
+``xy`` location of the rectangle which is stored as rect.xy and
+connect to the press, motion and release mouse events. When the mouse
+is pressed, check to see if the click occurs over your rectangle (see
+:meth:`matplotlib.patches.Rectangle.contains`) and if it does, store
+the rectangle xy and the location of the mouse click in data coords.
+In the motion event callback, compute the deltax and deltay of the
+mouse movement, and add those deltas to the origin of the rectangle
+you stored. The redraw the figure. On the button release event, just
+reset all the button press data you stored as None.
+
+Here is the solution::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ class DraggableRectangle:
+ def __init__(self, rect):
+ self.rect = rect
+ self.press = None
+
+ def connect(self):
+ 'connect to all the events we need'
+ self.cidpress = self.rect.figure.canvas.mpl_connect(
+ 'button_press_event', self.on_press)
+ self.cidrelease = self.rect.figure.canvas.mpl_connect(
+ 'button_release_event', self.on_release)
+ self.cidmotion = self.rect.figure.canvas.mpl_connect(
+ 'motion_notify_event', self.on_motion)
+
+ def on_press(self, event):
+ 'on button press we will see if the mouse is over us and store some data'
+ if event.inaxes != self.rect.axes: return
+
+ contains, attrd = self.rect.contains(event)
+ if not contains: return
+ print 'event contains', self.rect.xy
+ x0, y0 = self.rect.xy
+ self.press = x0, y0, event.xdata, event.ydata
+
+ def on_motion(self, event):
+ 'on motion we will move the rect if the mouse is over us'
+ if self.press is None: return
+ if event.inaxes != self.rect.axes: return
+ x0, y0, xpress, ypress = self.press
+ dx = event.xdata - xpress
+ dy = event.ydata - ypress
+ #print 'x0=%f, xpress=%f, event.xdata=%f, dx=%f, x0+dx=%f'%(x0, xpress, event.xdata, dx, x0+dx)
+ self.rect.set_x(x0+dx)
+ self.rect.set_y(y0+dy)
+
+ self.rect.figure.canvas.draw()
+
+
+ def on_release(self, event):
+ 'on release we reset the press data'
+ self.press = None
+ self.rect.figure.canvas.draw()
+
+ def disconnect(self):
+ 'disconnect all the stored connection ids'
+ self.rect.figure.canvas.mpl_disconnect(self.cidpress)
+ self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
+ self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ rects = ax.bar(range(10), 20*np.random.rand(10))
+ drs = []
+ for rect in rects:
+ dr = DraggableRectangle(rect)
+ dr.connect()
+ drs.append(dr)
+
 plt.show()
+
+
+**Extra credit**: use the animation blit techniques discussed in the
+`animations recipe
+<http://www.scipy.org/Cookbook/Matplotlib/Animations>`_ to make the
+animated drawing faster and smoother.
+
+Extra credit solution::
+
+ # draggable rectangle with the animation blit techniques; see
+ # http://www.scipy.org/Cookbook/Matplotlib/Animations
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ class DraggableRectangle:
+ lock = None # only one can be animated at a time
+ def __init__(self, rect):
+ self.rect = rect
+ self.press = None
+ self.background = None
+
+ def connect(self):
+ 'connect to all the events we need'
+ self.cidpress = self.rect.figure.canvas.mpl_connect(
+ 'button_press_event', self.on_press)
+ self.cidrelease = self.rect.figure.canvas.mpl_connect(
+ 'button_release_event', self.on_release)
+ self.cidmotion = self.rect.figure.canvas.mpl_connect(
+ 'motion_notify_event', self.on_motion)
+
+ def on_press(self, event):
+ 'on button press we will see if the mouse is over us and store some data'
+ if event.inaxes != self.rect.axes: return
+ if DraggableRectangle.lock is not None: return
+ contains, attrd = self.rect.contains(event)
+ if not contains: return
+ print 'event contains', self.rect.xy
+ x0, y0 = self.rect.xy
+ self.press = x0, y0, event.xdata, event.ydata
+ DraggableRectangle.lock = self
+
+ # draw everything but the selected rectangle and store the pixel buffer
+ canvas = self.rect.figure.canvas
+ axes = self.rect.axes
+ self.rect.set_animated(True)
+ canvas.draw()
+ self.background = canvas.copy_from_bbox(self.rect.axes.bbox)
+
+ # now redraw just the rectangle
+ axes.draw_artist(self.rect)
+
+ # and blit just the redrawn area
+ canvas.blit(axes.bbox)
+
+ def on_motion(self, event):
+ 'on motion we will move the rect if the mouse is over us'
+ if DraggableRectangle.lock is not self:
+ return
+ if event.inaxes != self.rect.axes: return
+ x0, y0, xpress, ypress = self.press
+ dx = event.xdata - xpress
+ dy = event.ydata - ypress
+ self.rect.set_x(x0+dx)
+ self.rect.set_y(y0+dy)
+
+ canvas = self.rect.figure.canvas
+ axes = self.rect.axes
+ # restore the background region
+ canvas.restore_region(self.background)
+
+ # redraw just the current rectangle
+ axes.draw_artist(self.rect)
+
+ # blit just the redrawn area
+ canvas.blit(axes.bbox)
+
+ def on_release(self, event):
+ 'on release we reset the press data'
+ if DraggableRectangle.lock is not self:
+ return
+
+ self.press = None
+ DraggableRectangle.lock = None
+
+ # turn off the rect animation property and reset the background
+ self.rect.set_animated(False)
+ self.background = None
+
+ # redraw the full figure
+ self.rect.figure.canvas.draw()
+
+ def disconnect(self):
+ 'disconnect all the stored connection ids'
+ self.rect.figure.canvas.mpl_disconnect(self.cidpress)
+ self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
+ self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ rects = ax.bar(range(10), 20*np.random.rand(10))
+ drs = []
+ for rect in rects:
+ dr = DraggableRectangle(rect)
+ dr.connect()
+ drs.append(dr)
+
+ plt.show()
+
+
+.. _enter-leave-events:
+
+Mouse enter and leave
+======================
+
+If you want to be notified when the mouse enters or leaves a figure or
+axes, you can connect to the figure/axes enter/leave events. Here is
+a simple example that changes the colors of the axes and figure
+background that the mouse is over::
+
+ """
+ Illustrate the figure and axes enter and leave events by changing the
+ frame colors on enter and leave
+ """
+ import matplotlib.pyplot as plt
+
+ def enter_axes(event):
+ print 'enter_axes', event.inaxes
+ event.inaxes.patch.set_facecolor('yellow')
+ event.canvas.draw()
+
+ def leave_axes(event):
+ print 'leave_axes', event.inaxes
+ event.inaxes.patch.set_facecolor('white')
+ event.canvas.draw()
+
+ def enter_figure(event):
+ print 'enter_figure', event.canvas.figure
+ event.canvas.figure.patch.set_facecolor('red')
+ event.canvas.draw()
+
+ def leave_figure(event):
+ print 'leave_figure', event.canvas.figure
+ event.canvas.figure.patch.set_facecolor('grey')
+ event.canvas.draw()
+
+ fig1 = plt.figure()
+ fig1.suptitle('mouse hover over figure or axes to trigger events')
+ ax1 = fig1.add_subplot(211)
+ ax2 = fig1.add_subplot(212)
+
+ fig1.canvas.mpl_connect('figure_enter_event', enter_figure)
+ fig1.canvas.mpl_connect('figure_leave_event', leave_figure)
+ fig1.canvas.mpl_connect('axes_enter_event', enter_axes)
+ fig1.canvas.mpl_connect('axes_leave_event', leave_axes)
+
+ fig2 = plt.figure()
+ fig2.suptitle('mouse hover over figure or axes to trigger events')
+ ax1 = fig2.add_subplot(211)
+ ax2 = fig2.add_subplot(212)
+
+ fig2.canvas.mpl_connect('figure_enter_event', enter_figure)
+ fig2.canvas.mpl_connect('figure_leave_event', leave_figure)
+ fig2.canvas.mpl_connect('axes_enter_event', enter_axes)
+ fig2.canvas.mpl_connect('axes_leave_event', leave_axes)
+
+ plt.show()
+
+
+
+.. _object-picking:
+
+Object picking
+==============
+
+You can enable picking by setting the ``picker`` property of an
+:class:`~matplotlib.artist.Artist` (eg a matplotlib
+:class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.text.Text`,
+:class:`~matplotlib.patches.Patch`, :class:`~matplotlib.patches.Polygon`,
+:class:`~matplotlib.patches.AxesImage`, etc...)
+
+There are a variety of meanings of the ``picker`` property:
+
+ ``None``
+	picking is disabled for this artist (default)
+
+ ``boolean``
+	if True then picking will be enabled and the artist will fire a
+	pick event if the mouse event is over the artist
+
+ ``float``
+	if picker is a number it is interpreted as an epsilon tolerance in
+	points and the the artist will fire off an event if its data is
+	within epsilon of the mouse event. For some artists like lines
+	and patch collections, the artist may provide additional data to
+	the pick event that is generated, eg the indices of the data
+	within epsilon of the pick event.
+
+ ``function``
+	if picker is callable, it is a user supplied function which
+	determines whether the artist is hit by the mouse event. The
+	signature is ``hit, props = picker(artist, mouseevent)`` to
+	determine the hit test. If the mouse event is over the artist,
+	return ``hit=True`` and props is a dictionary of properties you
+	want added to the :class:`~matplotlib.backend_bases.PickEvent`
+	attributes
+
+
+After you have enabled an artist for picking by setting the ``picker``
+property, you need to connect to the figure canvas pick_event to get
+pick callbacks on mouse press events. Eg::
+
+ def pick_handler(event):
+ mouseevent = event.mouseevent
+ artist = event.artist
+ # now do something with this...
+
+
+The :class:`~matplotlib.backend_bases.PickEvent` which is passed to
+your callback is always fired with two attributes:
+
+ ``mouseevent`` the mouse event that generate the pick event. The
+	mouse event in turn has attributes like ``x`` and ``y`` (the
+	coords in display space, eg pixels from left, bottom) and xdata,
+	ydata (the coords in data space). Additionally, you can get
+	information about which buttons were pressed, which keys were
+	pressed, which :class:`~matplotlib.axes.Axes` the mouse is over,
+	etc. See :class:`matplotlib.backend_bases.MouseEvent` for
+	details.
+
+ ``artist``
+	the :class:`~matplotlib.artist.Artist` that generated the pick
+	event.
+
+Additionally, certain artists like :class:`~matplotlib.lines.Line2D`
+and :class:`~matplotlib.collections.PatchCollection` may attach
+additional meta data like the indices into the data that meet the
+picker criteria (eg all the points in the line that are within the
+specified epsilon tolerance)
+
+Simple picking example
+----------------------
+
+In the example below, we set the line picker property to a scalar, so
+it represents a tolerance in points (72 points per inch). The onpick
+callback function will be called when the pick event it within the
+tolerance distance from the line, and has the indices of the data
+vertices that are within the pick distance tolerance. Our onpick
+callback function simply prints the data that are under the pick
+location. Different matplotlib Artists can attach different data to
+the PickEvent. For example, ``Line2D`` attaches the ind property,
+which are the indices into the line data under the pick point. See
+:meth:`~matplotlib.lines.Line2D.pick` for details on the ``PickEvent``
+properties of the line. Here is the code::
+
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.set_title('click on points')
+
+ line, = ax.plot(np.random.rand(100), 'o', picker=5) # 5 points tolerance
+
+ def onpick(event):
+ thisline = event.artist
+ xdata = thisline.get_xdata()
+ ydata = thisline.get_ydata()
+ ind = event.ind
+ print 'onpick points:', zip(xdata[ind], ydata[ind])
+
+ fig.canvas.mpl_connect('pick_event', onpick)
+
+ plt.show()
+
+
+Picking exercise
+----------------
+
+Create a data set of 100 arrays of 1000 Gaussian random numbers and
+compute the sample mean and standard deviation of each of them (hint:
+numpy arrays have a mean and std method) and make a xy marker plot of
+the 100 means vs the 100 standard deviations. Connect the line
+created by the plot command to the pick event, and plot the original
+time series of the data that generated the clicked on points. If more
+than one point is within the tolerance of the clicked on point, you
+can use multiple subplots to plot the multiple time series.
+
+Exercise solution::
+
+ """
+ compute the mean and stddev of 100 data sets and plot mean vs stddev.
+ When you click on one of the mu, sigma points, plot the raw data from
+ the dataset that generated the mean and stddev
+ """
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ X = np.random.rand(100, 1000)
+ xs = np.mean(X, axis=1)
+ ys = np.std(X, axis=1)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ ax.set_title('click on point to plot time series')
+ line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
+
+
+ def onpick(event):
+
+ if event.artist!=line: return True
+
+ N = len(event.ind)
+ if not N: return True
+
+
+ figi = plt.figure()
+ for subplotnum, dataind in enumerate(event.ind):
+ ax = figi.add_subplot(N,1,subplotnum+1)
+ ax.plot(X[dataind])
+ ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
+ transform=ax.transAxes, va='top')
+ ax.set_ylim(-0.5, 1.5)
+ figi.show()
+ return True
+
+ fig.canvas.mpl_connect('pick_event', onpick)
+
+ plt.show()
Modified: branches/v0_99_maint/doc/users/pyplot_tutorial.rst
===================================================================
--- branches/v0_99_maint/doc/users/pyplot_tutorial.rst	2009年08月07日 00:42:20 UTC (rev 7413)
+++ branches/v0_99_maint/doc/users/pyplot_tutorial.rst	2009年08月07日 10:15:04 UTC (rev 7414)
@@ -74,7 +74,7 @@
 one line so it is a list of length 1. I use tuple unpacking in the
 ``line, = plot(x, y, 'o')`` to get the first element of the list::
 
- line, = plt.plot(x, y, 'o')
+		 line, = plt.plot(x, y, '-')
 line.set_antialiased(False) # turn off antialising
 
 * Use the :func:`~matplotlib.pyplot.setp` command. The example below
@@ -156,7 +156,7 @@
 :func:`~matplotlib.pyplot.gcf` returns the current figure
 (:class:`matplotlib.figure.Figure` instance). Normally, you don't have
 to worry about this, because it is all taken care of behind the
-scenes. Below is an script to create two subplots.
+scenes. Below is a script to create two subplots.
 
 .. plot:: pyplots/pyplot_two_subplots.py
 :include-source:
@@ -165,18 +165,16 @@
 ``figure(1)`` will be created by default, just as a ``subplot(111)``
 will be created by default if you don't manually specify an axes. The
 :func:`~matplotlib.pyplot.subplot` command specifies ``numrows,
-numcols, fignum`` where ``fignum`` ranges from 1 to
-``numrows*numcols``. The commas in the ``subplot command are optional
+	 numcols, fignum`` where ``fignum`` ranges from 1 to
+``numrows*numcols``. The commas in the ``subplot`` command are optional
 if ``numrows*numcols<10``. So ``subplot(211)`` is identical to
 ``subplot(2,1,1)``. You can create an arbitrary number of subplots
 and axes. If you want to place an axes manually, ie, not on a
 rectangular grid, use the :func:`~matplotlib.pyplot.axes` command,
 which allows you to specify the location as ``axes([left, bottom,
 width, height])`` where all values are in fractional (0 to 1)
-coordinates. See `axes_demo.py
-<http://matplotlib.sf.net/examples/axes_demo.py>`_ for an example of
-placing axes manually and `line_styles.py
-<http://matplotlib.sf.net/examples/line_styles.py>`_ for an example
+coordinates. See :ref:`pylab_examples-axes_demo` for an example of
+placing axes manually and :ref:`pylab_examples-line_styles` for an example
 with lots-o-subplots.
 
 
@@ -269,6 +267,6 @@
 In this basic example, both the ``xy`` (arrow tip) and ``xytext``
 locations (text location) are in data coordinates. There are a
 variety of other coordinate systems one can choose -- see
-:ref:`annotations-tutorial` for details. More examples can be found
-in the `annotations demo
-<http://matplotlib.sf.net/examples/pylab_examples/annotation_demo.html>`_
+:ref:`annotations-tutorial` and :ref:`plotting-guide-annotation`
+for details. More examples can be found
+in :ref:`pylab_examples-annotation_demo`.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月07日 00:42:33
Revision: 7413
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7413&view=rev
Author: jswhit
Date: 2009年08月07日 00:42:20 +0000 (2009年8月07日)
Log Message:
-----------
update version number
Modified Paths:
--------------
 trunk/toolkits/basemap/doc/conf.py
Modified: trunk/toolkits/basemap/doc/conf.py
===================================================================
--- trunk/toolkits/basemap/doc/conf.py	2009年08月07日 00:38:17 UTC (rev 7412)
+++ trunk/toolkits/basemap/doc/conf.py	2009年08月07日 00:42:20 UTC (rev 7413)
@@ -46,9 +46,9 @@
 # other places throughout the built documents.
 #
 # The short X.Y version.
-version = '0.99.3'
+version = '0.99.4'
 # The full version, including alpha/beta/rc tags.
-release = '0.99.3'
+release = '0.99.4'
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7412
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7412&view=rev
Author: jswhit
Date: 2009年08月07日 00:38:17 +0000 (2009年8月07日)
Log Message:
-----------
make sure contour lines and filled contour intervals are consistent
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/contour_demo.py
Modified: trunk/toolkits/basemap/examples/contour_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/contour_demo.py	2009年08月06日 20:27:58 UTC (rev 7411)
+++ trunk/toolkits/basemap/examples/contour_demo.py	2009年08月07日 00:38:17 UTC (rev 7412)
@@ -19,13 +19,15 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # make a filled contour plot.
 x, y = m(lons, lats)
-CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
+# create contour lines
+CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
+# fill between contour lines.
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet)
 # setup colorbar axes instance.
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
-plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.colorbar(CS2, drawedges=True, cax=cax) # draw colorbar
 plt.axes(ax) # make the original axes current again
 # draw coastlines and political boundaries.
 m.drawcoastlines()
@@ -46,12 +48,12 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # make a filled contour plot.
 x, y = m(lons, lats)
-CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
+CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet)
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
-plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.colorbar(CS2, drawedges=True, cax=cax) # draw colorbar
 plt.axes(ax) # make the original axes current again
 # draw coastlines and political boundaries.
 m.drawcoastlines()
@@ -72,12 +74,12 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # make a filled contour plot.
 x, y = m(lons, lats)
-CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
+CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
+CS2 = m.contourf(x,y,hgt,CS1.levels,cmap=plt.cm.jet)
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
-plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.colorbar(CS2, drawedges=True, cax=cax) # draw colorbar
 plt.axes(ax) # make the original axes current again
 # draw coastlines and political boundaries.
 m.drawcoastlines()
@@ -98,12 +100,12 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # make a filled contour plot.
 x, y = m(lons, lats)
-CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
+CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
+CS2 = m.contourf(x,y,hgt,CS2.levels,cmap=plt.cm.jet)
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
-plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.colorbar(CS2, drawedges=True, cax=cax) # draw colorbar
 plt.axes(ax) # make the original axes current again
 # draw coastlines and political boundaries.
 m.drawcoastlines()
@@ -125,12 +127,12 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # make a filled contour plot.
 x, y = m(lons, lats)
-CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
-CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
+CS1 = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
+CS2 = m.contourf(x,y,hgt,CS2.levels,cmap=plt.cm.jet)
 pos = ax.get_position()
 l, b, w, h = pos.bounds
 cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
-plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.colorbar(CS2, drawedges=True, cax=cax) # draw colorbar
 plt.axes(ax) # make the original axes current again
 # draw coastlines and political boundaries.
 m.drawcoastlines()
@@ -144,4 +146,3 @@
 plt.title('Orthographic Filled Contour Demo')
 print 'plotting with orthographic basemap ..'
 plt.show()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 9 results of 9

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 によって変換されたページ (->オリジナル) /