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) |
|
|
|
|
|
Revision: 7505 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7505&view=rev Author: efiring Date: 2009年08月18日 22:18:59 +0000 (2009年8月18日) Log Message: ----------- Small cleanup of logic in handling drawstyle in Line2D Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2009年08月18日 22:13:11 UTC (rev 7504) +++ trunk/matplotlib/lib/matplotlib/lines.py 2009年08月18日 22:18:59 UTC (rev 7505) @@ -99,6 +99,8 @@ drawStyles = {} drawStyles.update(_drawStyles_l) drawStyles.update(_drawStyles_s) + # Need a list ordered with long names first: + drawStyleKeys = _drawStyles_l.keys() + _drawStyles_s.keys() markers = _markers = { # hidden names deprecated '.' : '_draw_point', @@ -712,15 +714,14 @@ any drawstyle in combination with a linestyle, e.g. 'steps--'. """ - # handle long drawstyle names before short ones ! - for ds in flatten([k.keys() for k in (self._drawStyles_l, - self._drawStyles_s)], is_string_like): + for ds in self.drawStyleKeys: # long names are first in the list if linestyle.startswith(ds): self.set_drawstyle(ds) if len(linestyle) > len(ds): linestyle = linestyle[len(ds):] else: linestyle = '-' + break if linestyle not in self._lineStyles: if linestyle in ls_mapper: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7504 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7504&view=rev Author: mdboom Date: 2009年08月18日 22:13:11 +0000 (2009年8月18日) Log Message: ----------- Fix clipping on collections. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/collections.py Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2009年08月18日 21:59:07 UTC (rev 7503) +++ trunk/matplotlib/lib/matplotlib/collections.py 2009年08月18日 22:13:11 UTC (rev 7504) @@ -208,8 +208,7 @@ 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()) + self._set_gc_clip(gc) renderer.draw_path_collection( gc, transform.frozen(), paths, self.get_transforms(), @@ -1210,8 +1209,7 @@ transOffset = transOffset.get_affine() gc = renderer.new_gc() - gc.set_clip_rectangle(self.get_clip_box()) - gc.set_clip_path(self.get_clip_path()) + self._set_clip_gc(gc) if self._shading == 'gouraud': triangles, colors = self.convert_mesh_to_triangles( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7503 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7503&view=rev Author: pkienzle Date: 2009年08月18日 21:59:07 +0000 (2009年8月18日) Log Message: ----------- devel docs: minor typo Modified Paths: -------------- trunk/matplotlib/doc/devel/documenting_mpl.rst Modified: trunk/matplotlib/doc/devel/documenting_mpl.rst =================================================================== --- trunk/matplotlib/doc/devel/documenting_mpl.rst 2009年08月18日 14:08:27 UTC (rev 7502) +++ trunk/matplotlib/doc/devel/documenting_mpl.rst 2009年08月18日 21:59:07 UTC (rev 7503) @@ -286,7 +286,7 @@ .. literalinclude:: ../../lib/matplotlib/mpl-data/matplotlibrc -On exception to this is when referring to the examples dir. Relative +One exception to this is when referring to the examples dir. Relative paths are extremely confusing in the sphinx plot extensions, so without getting into the dirty details, it is easier to simply include a symlink to the files at the top doc level directory. This way, API This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7502 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7502&view=rev Author: mdboom Date: 2009年08月18日 14:08:27 +0000 (2009年8月18日) Log Message: ----------- Fix some minor typos in the paths tutorial Modified Paths: -------------- branches/v0_99_maint/doc/users/path_tutorial.rst Modified: branches/v0_99_maint/doc/users/path_tutorial.rst =================================================================== --- branches/v0_99_maint/doc/users/path_tutorial.rst 2009年08月18日 14:01:41 UTC (rev 7501) +++ branches/v0_99_maint/doc/users/path_tutorial.rst 2009年08月18日 14:08:27 UTC (rev 7502) @@ -6,9 +6,9 @@ The object underlying all of the :mod:`matplotlib.patch` objects is the :class:`~matplotlib.path.Path`, which supports the standard set of -moveto, lineto, curveto commands to draw simple and compoud outlines +moveto, lineto, curveto commands to draw simple and compound outlines consisting of line segments and splines. The ``Path`` is instantiated -with a (N,2) array of (x,y) vertices, and a N length array of path +with a (N,2) array of (x,y) vertices, and a N-length array of path codes. For example to draw the unit rectangle from (0,0) to (1,1), we could use this code @@ -53,24 +53,24 @@ ``STOP`` 1 (ignored) A marker for the end of the entire path (currently not required and ignored) ``MOVETO`` 1 Pick up the pen and move to the given vertex. ``LINETO`` 1 Draw a line from the current position to the given vertex. -``CURVE3`` 2 (1 control point, 1 endpoint) Draw a quadratic Bezier curve from the current position, with the given control point, to the given end point. -``CURVE4`` 3 (2 control points, 1 endpoint) Draw a cubic Bezier curve from the current position, with the given control points, to the given end point. -``CLOSEPOLY`` 1 (ignored) Draw a line segment to the start point of the current polyline. +``CURVE3`` 2 (1 control point, 1 endpoint) Draw a quadratic Bézier curve from the current position, with the given control point, to the given end point. +``CURVE4`` 3 (2 control points, 1 endpoint) Draw a cubic Bézier curve from the current position, with the given control points, to the given end point. +``CLOSEPOLY`` 1 (point itself is ignored) Draw a line segment to the start point of the current polyline. ============== ================================= ==================================================================================================================== .. path-curves: -Bezier example +Bézier example ============== Some of the path components require multiple vertices to specify them: -for example CURVE 3 is a `bezier +for example CURVE 3 is a `bézier <http://en.wikipedia.org/wiki/B%C3%A9zier_curve>`_ curve with one control point and one end point, and CURVE4 has three vertices for the two control points and the end point. The example below shows a -CURVE4 Bezier spline -- the bezier curve will be contained in the +CURVE4 Bézier spline -- the bézier curve will be contained in the convex hul of the start point, the two control points, and the end point @@ -175,7 +175,7 @@ verts[3::5,1] = bottom All that remains is to create the path, attach it to a -:class:`~matplotlib.patch.PathPatch`, and ad it to our axes:: +:class:`~matplotlib.patch.PathPatch`, and add it to our axes:: barpath = path.Path(verts, codes) patch = patches.PathPatch(barpath, facecolor='green', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7501 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7501&view=rev Author: mdboom Date: 2009年08月18日 14:01:41 +0000 (2009年8月18日) Log Message: ----------- Fix some minor typos in the transforms tutorial Modified Paths: -------------- branches/v0_99_maint/doc/users/transforms_tutorial.rst Modified: branches/v0_99_maint/doc/users/transforms_tutorial.rst =================================================================== --- branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009年08月18日 14:00:28 UTC (rev 7500) +++ branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009年08月18日 14:01:41 UTC (rev 7501) @@ -348,7 +348,10 @@ and zoom. There is an efficiency here, because you can pan and zoom in your axes which affects the affine transformation, but you may not need to compute the potentially expensive nonlinear scales or -projections on simple navigation events. +projections on simple navigation events. It is also possible to +multiply affine transformation matrices togeter, and then apply them +to coordinates in one step. This is not true of all possible +transformations. Here is how the ``ax.transData`` instance is defined in the basic This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7500 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7500&view=rev Author: mdboom Date: 2009年08月18日 14:00:28 +0000 (2009年8月18日) Log Message: ----------- Fix some minor typos in the transforms tutorial Modified Paths: -------------- branches/v0_99_maint/doc/users/transforms_tutorial.rst Modified: branches/v0_99_maint/doc/users/transforms_tutorial.rst =================================================================== --- branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009年08月18日 05:15:21 UTC (rev 7499) +++ branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009年08月18日 14:00:28 UTC (rev 7500) @@ -34,7 +34,7 @@ `Transformation Object` column -- it already is in display coordinates. The transformations also know how to invert themselves, to go from `display` back to the native coordinate system. This is -particularly useful when processing events frmo the user interface, +particularly useful when processing events from the user interface, which typically occur in display space, and you want to know where the mouse click or key-press occurred in your data coordinate system. @@ -44,8 +44,8 @@ ================ Let's start with the most commonly used coordinate, the `data` -coordinate system. Whenever, you add data to the axes, matplotlib -updates the datalimits, most commonly updated in with the +coordinate system. Whenever you add data to the axes, matplotlib +updates the datalimits, most commonly updated with the :meth:`~matplotlib.axes.Axes.set_xlim` and :meth:`~matplotlib.axes.Axes.set_ylim` methods. For example, in the figure below, the data limits stretch from 0 to 10 on the x-axis, and @@ -85,7 +85,7 @@ array([[ 335.175, 247. ], [ 132.435, 642.2 ]]) -You can use the :meth`~matplotlib.transforms.Transform.inverted` +You can use the :meth:`~matplotlib.transforms.Transform.inverted` method to create a transform which will take you from display to data coordinates: @@ -152,15 +152,15 @@ ================ After the `data` coordinate system, `axes` is probably the second most -useful coordinate system. Here the point (0,0) is the bottom left -of your axes or subplot, (0.5, 0.5) is the center, and (1.0, -1.0) is the top right. You can also refer to points outside the -range, so (-0.1, 1.1) is to the left and above your axes. This -coordinate system is extremely useful when making placing text in your -axes, because you often want a text bubble in a fixed, location, eg -the upper left of the axes pane, and have that location remain fixed -when you pan or zoom. Here is a simple example that creates four -panels and labels them 'A', 'B', 'C', 'D' as you often see in journals. +useful coordinate system. Here the point (0,0) is the bottom left of +your axes or subplot, (0.5, 0.5) is the center, and (1.0, 1.0) is the +top right. You can also refer to points outside the range, so (-0.1, +1.1) is to the left and above your axes. This coordinate system is +extremely useful when placing text in your axes, because you often +want a text bubble in a fixed, location, eg. the upper left of the axes +pane, and have that location remain fixed when you pan or zoom. Here +is a simple example that creates four panels and labels them 'A', 'B', +'C', 'D' as you often see in journals. .. plot:: :include-source: @@ -265,7 +265,7 @@ ================================================= One use of transformations is to create a new transformation that is -offset from another annotation, eg to place one object shited a bit +offset from another annotation, eg to place one object shifted a bit relative to another object. Typically you want the shift to be in some physical dimension, like points or inches rather than in data coordinates, so that the shift effect is constant at different zoom @@ -285,12 +285,12 @@ a transformation which scales `xt` and `yt` at transformation time before applying the offsets. A typical use case is to use the figure ``fig.dpi_scale_trans`` transformation for the `scale_trans` argument, -to first scale `xty and `yt` specified in points to `display` space +to first scale `xt` and `yt` specified in points to `display` space before doing the final offset. The dpi and inches offset is a common-enough use case that we have a special helper function to create it in :func:`matplotlib.transforms.offset_copy`, which returns a new transform with an added offset. But in the example below, we'll -create the offset trransform ourselves. Note the use of the plus +create the offset transform ourselves. Note the use of the plus operator in:: offset = transforms.ScaledTranslation(dx, dy, @@ -298,7 +298,7 @@ shadow_transform = ax.transData + offset showing that can chain transformations using the addition operator. -This code say: first appy the data transformation ``ax.transData`` and +This code says: first appy the data transformation ``ax.transData`` and then translate the data by `dx` and `dy` points. .. plot:: @@ -342,12 +342,12 @@ tutorial is a composite of three different transformations that comprise the transformation pipeline from `data` -> `display` coordinates. Michael Droettboom implemented the transformations -frameowk, taking care to provide a clean API that segregated the +framework, taking care to provide a clean API that segregated the nonlinear projections and scales that happen in polar and logarithmic plots, from the linear affine transformations that happen when you pan and zoom. There is an efficiency here, because you can pan and zoom in your axes which affects the affine transformation, but you may not -need to compte the potentially expensice nonlinear scales or +need to compute the potentially expensive nonlinear scales or projections on simple navigation events. @@ -361,8 +361,8 @@ axes or subplot bounding box to `display` space, so let's look at these other two pieces. -``self.transLimits`` is the transformation that takes your from -``data`` to ``axes`` coordinates; ie, it maps your view xlim and ylim +``self.transLimits`` is the transformation that takes you from +``data`` to ``axes`` coordinates; i.e., it maps your view xlim and ylim to the unit space of the axes (and ``transAxes`` then takes that unit space to display space). We can see this in action here @@ -397,7 +397,7 @@ Out[90]: array([ 2.5, -0.5]) The final piece is the ``self.transScale`` attribute, which is -responsible for the optional non-linear scaling of the data, eg for +responsible for the optional non-linear scaling of the data, eg. for logarithmic axes. When an Axes is initally setup, this is just set to the identity transform, since the basic matplotlib axes has linear scale, but when you call a logarithmic scaling function like @@ -418,12 +418,13 @@ self.transData = self.transScale + self.transProjection + \ (self.transProjectionAffine + self.transAxes) -``transProjection`` handles the projection from the space, eg latitude and longitude -for map data, or radius and theta for polar data, to a separable -cartesian coordinate system. There are several projection examples in -the ``matplotlib.projections`` package, and the best way to learn more -is to open the source for those packages and see how to make your own, -since matplotlib supports extensible axes and projections. Michael -Droettboom has provided a nice tutorial example of creating a hammer -projection axes; see :ref:`api-custom_projection_example`. +``transProjection`` handles the projection from the space, +eg. latitude and longitude for map data, or radius and theta for polar +data, to a separable cartesian coordinate system. There are several +projection examples in the ``matplotlib.projections`` package, and the +best way to learn more is to open the source for those packages and +see how to make your own, since matplotlib supports extensible axes +and projections. Michael Droettboom has provided a nice tutorial +example of creating a hammer projection axes; see +:ref:`api-custom_projection_example`. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7499 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7499&view=rev Author: jdh2358 Date: 2009年08月18日 05:15:21 +0000 (2009年8月18日) Log Message: ----------- added looking glass demo Added Paths: ----------- branches/v0_99_maint/examples/event_handling/looking_glass.py Added: branches/v0_99_maint/examples/event_handling/looking_glass.py =================================================================== --- branches/v0_99_maint/examples/event_handling/looking_glass.py (rev 0) +++ branches/v0_99_maint/examples/event_handling/looking_glass.py 2009年08月18日 05:15:21 UTC (rev 7499) @@ -0,0 +1,47 @@ +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.patches as patches +x, y = np.random.rand(2, 200) + +fig = plt.figure() +ax = fig.add_subplot(111) +circ = patches.Circle( (0.5, 0.5), 0.25, alpha=0.8, fc='yellow') +ax.add_patch(circ) + + +ax.plot(x, y, alpha=0.2) +line, = ax.plot(x, y, alpha=1.0, clip_path=circ) + +class EventHandler: + def __init__(self): + fig.canvas.mpl_connect('button_press_event', self.onpress) + fig.canvas.mpl_connect('button_release_event', self.onrelease) + fig.canvas.mpl_connect('motion_notify_event', self.onmove) + self.x0, self.y0 = circ.center + self.pressevent = None + + def onpress(self, event): + if event.inaxes!=ax: + return + + if not circ.contains(event): + return + + self.pressevent = event + + def onrelease(self, event): + self.pressevent = None + self.x0, self.y0 = circ.center + + def onmove(self, event): + if self.pressevent is None or event.inaxes!=self.pressevent.inaxes: + return + + dx = event.xdata - self.pressevent.xdata + dy = event.ydata - self.pressevent.ydata + circ.center = self.x0 + dx, self.y0 + dy + line.set_clip_path(circ) + fig.canvas.draw() + +handler = EventHandler() +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7498 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7498&view=rev Author: jdh2358 Date: 2009年08月18日 03:48:21 +0000 (2009年8月18日) Log Message: ----------- added path tut Modified Paths: -------------- branches/v0_99_maint/doc/users/index.rst Added Paths: ----------- branches/v0_99_maint/doc/pyplots/compound_path_demo.py branches/v0_99_maint/doc/users/path_tutorial.rst Added: branches/v0_99_maint/doc/pyplots/compound_path_demo.py =================================================================== --- branches/v0_99_maint/doc/pyplots/compound_path_demo.py (rev 0) +++ branches/v0_99_maint/doc/pyplots/compound_path_demo.py 2009年08月18日 03:48:21 UTC (rev 7498) @@ -0,0 +1,42 @@ +import numpy as np + +import matplotlib.pyplot as plt +import matplotlib.patches as patches +import matplotlib.path as path + +fig = plt.figure() +ax = fig.add_subplot(111) + +# histogram our data with numpy +data = np.random.randn(1000) +n, bins = np.histogram(data, 100) + +# get the corners of the rectangles for the histogram +left = np.array(bins[:-1]) +right = np.array(bins[1:]) +bottom = np.zeros(len(left)) +top = bottom + n +nrects = len(left) + +nverts = nrects*(1+3+1) +verts = np.zeros((nverts, 2)) +codes = np.ones(nverts, int) * path.Path.LINETO +codes[0::5] = path.Path.MOVETO +codes[4::5] = path.Path.CLOSEPOLY +verts[0::5,0] = left +verts[0::5,1] = bottom +verts[1::5,0] = left +verts[1::5,1] = top +verts[2::5,0] = right +verts[2::5,1] = top +verts[3::5,0] = right +verts[3::5,1] = bottom + +barpath = path.Path(verts, codes) +patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5) +ax.add_patch(patch) + +ax.set_xlim(left[0], right[-1]) +ax.set_ylim(bottom.min(), top.max()) + +plt.show() Modified: branches/v0_99_maint/doc/users/index.rst =================================================================== --- branches/v0_99_maint/doc/users/index.rst 2009年08月18日 02:41:43 UTC (rev 7497) +++ branches/v0_99_maint/doc/users/index.rst 2009年08月18日 03:48:21 UTC (rev 7498) @@ -25,6 +25,7 @@ annotations_guide.rst legend.rst transforms_tutorial.rst + path_tutorial.rst toolkits.rst screenshots.rst whats_new.rst Added: branches/v0_99_maint/doc/users/path_tutorial.rst =================================================================== --- branches/v0_99_maint/doc/users/path_tutorial.rst (rev 0) +++ branches/v0_99_maint/doc/users/path_tutorial.rst 2009年08月18日 03:48:21 UTC (rev 7498) @@ -0,0 +1,187 @@ +.. _path_tutorial: + +************* +Path Tutorial +************* + +The object underlying all of the :mod:`matplotlib.patch` objects is +the :class:`~matplotlib.path.Path`, which supports the standard set of +moveto, lineto, curveto commands to draw simple and compoud outlines +consisting of line segments and splines. The ``Path`` is instantiated +with a (N,2) array of (x,y) vertices, and a N length array of path +codes. For example to draw the unit rectangle from (0,0) to (1,1), we +could use this code + +.. plot:: + :include-source: + + import matplotlib.pyplot as plt + from matplotlib.path import Path + import matplotlib.patches as patches + + verts = [ + (0., 0.), # left, bottom + (0., 1.), # left, top + (1., 1.), # right, top + (1., 0.), # right, bottom + (0., 0.), # ignored + ] + + codes = [Path.MOVETO, + Path.LINETO, + Path.LINETO, + Path.LINETO, + Path.CLOSEPOLY, + ] + + path = Path(verts, codes) + + fig = plt.figure() + ax = fig.add_subplot(111) + patch = patches.PathPatch(path, facecolor='orange', lw=2) + ax.add_patch(patch) + ax.set_xlim(-2,2) + ax.set_ylim(-2,2) + plt.show() + + +The following path codes are recognized + +============== ================================= ==================================================================================================================== +Code Vertices Description +============== ================================= ==================================================================================================================== +``STOP`` 1 (ignored) A marker for the end of the entire path (currently not required and ignored) +``MOVETO`` 1 Pick up the pen and move to the given vertex. +``LINETO`` 1 Draw a line from the current position to the given vertex. +``CURVE3`` 2 (1 control point, 1 endpoint) Draw a quadratic Bezier curve from the current position, with the given control point, to the given end point. +``CURVE4`` 3 (2 control points, 1 endpoint) Draw a cubic Bezier curve from the current position, with the given control points, to the given end point. +``CLOSEPOLY`` 1 (ignored) Draw a line segment to the start point of the current polyline. +============== ================================= ==================================================================================================================== + + +.. path-curves: + + +Bezier example +============== + +Some of the path components require multiple vertices to specify them: +for example CURVE 3 is a `bezier +<http://en.wikipedia.org/wiki/B%C3%A9zier_curve>`_ curve with one +control point and one end point, and CURVE4 has three vertices for the +two control points and the end point. The example below shows a +CURVE4 Bezier spline -- the bezier curve will be contained in the +convex hul of the start point, the two control points, and the end +point + +.. plot:: + :include-source: + + import matplotlib.pyplot as plt + from matplotlib.path import Path + import matplotlib.patches as patches + + verts = [ + (0., 0.), # P0 + (0.2, 1.), # P1 + (1., 0.8), # P2 + (0.8, 0.), # P3 + ] + + codes = [Path.MOVETO, + Path.CURVE4, + Path.CURVE4, + Path.CURVE4, + ] + + path = Path(verts, codes) + + fig = plt.figure() + ax = fig.add_subplot(111) + patch = patches.PathPatch(path, facecolor='none', lw=2) + ax.add_patch(patch) + + xs, ys = zip(*verts) + ax.plot(xs, ys, 'x--', lw=2, color='black', ms=10) + + ax.text(-0.05, -0.05, 'P0') + ax.text(0.15, 1.05, 'P1') + ax.text(1.05, 0.85, 'P2') + ax.text(0.85, -0.05, 'P3') + + ax.set_xlim(-0.1, 1.1) + ax.set_ylim(-0.1, 1.1) + plt.show() + +.. compound_paths: + +Compound paths +============== + +All of the simple patch primitives in matplotlib, Rectangle, Circle, +Polygon, etc, are implemented with simple path. Plotting functions +like :meth:`~matplotlib.axes.Axes.hist` and +:meth:`~matplotlib.axes.Axes.bar`, which create a number of +primitives, eg a bunch of Rectangles, can usually be implemented more +efficiently using a compund path. The reason ``bar`` creates a list +of rectangles and not a compound path is largely historical: the +:class:`~matplotlib.path.Path` code is comparatively new and ``bar`` +predates it. While we could change it now, it would break old code, +so here we will cover how to create compound paths, replacing the +functionality in bar, in case you need to do so in your own code for +efficiency reasons, eg you are creating an animated bar plot. + +We will make the histogram chart by creating a series of rectangles +for each histogram bar: the rectangle width is the bin width and the +rectangle height is the number of datapoints in that bin. First we'll +create some random normally distributed data and compute the +histogram. Because numpy returns the bin edges and not centers, the +length of ``bins`` is 1 greater than the length of ``n`` in the +example below:: + + # histogram our data with numpy + data = np.random.randn(1000) + n, bins = np.histogram(data, 100) + +We'll now extract the corners of the rectangles. Each of the +``left``, ``bottom``, etc, arrays below is ``len(n)``, where ``n`` is +the array of counts for each histogram bar:: + + # get the corners of the rectangles for the histogram + left = np.array(bins[:-1]) + right = np.array(bins[1:]) + bottom = np.zeros(len(left)) + top = bottom + n + +Now we have to construct our compound path, which will consist of a +series of ``MOVETO``, ``LINETO`` and ``CLOSEPOLY`` for each rectangle. +For each rectangle, we need 5 vertices: 1 for the ``MOVETO``, 3 for +the ``LINETO``, and 1 for the ``CLOSEPOLY``. As indicated in the +table above, the vertex for the closepoly is ignored but we still need +it to keep the codes aligned with the vertices:: + + nverts = nrects*(1+3+1) + verts = np.zeros((nverts, 2)) + codes = np.ones(nverts, int) * path.Path.LINETO + codes[0::5] = path.Path.MOVETO + codes[4::5] = path.Path.CLOSEPOLY + verts[0::5,0] = left + verts[0::5,1] = bottom + verts[1::5,0] = left + verts[1::5,1] = top + verts[2::5,0] = right + verts[2::5,1] = top + verts[3::5,0] = right + verts[3::5,1] = bottom + +All that remains is to create the path, attach it to a +:class:`~matplotlib.patch.PathPatch`, and ad it to our axes:: + + barpath = path.Path(verts, codes) + patch = patches.PathPatch(barpath, facecolor='green', + edgecolor='yellow', alpha=0.5) + ax.add_patch(patch) + +Here is the result + +.. plot:: pyplots/compound_path_demo.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7497 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7497&view=rev Author: efiring Date: 2009年08月18日 02:41:43 +0000 (2009年8月18日) Log Message: ----------- Remove unmasked_index_ranges from lines.py; it is still in cbook.py Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2009年08月15日 23:51:39 UTC (rev 7496) +++ trunk/matplotlib/lib/matplotlib/lines.py 2009年08月18日 02:41:43 UTC (rev 7497) @@ -26,15 +26,6 @@ CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = range(8) -# COVERAGE NOTE: Never called internally or from examples -def unmasked_index_ranges(mask, compressed = True): - warnings.warn("Import this directly from matplotlib.cbook", - DeprecationWarning) - # Warning added 2008年07月22日 - from matplotlib.cbook import unmasked_index_ranges as _unmasked_index_ranges - return _unmasked_index_ranges(mask, compressed=compressed) - - def segment_hits(cx, cy, x, y, radius): """ Determine if any line segments are within radius of a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.