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
|
|
From: <lee...@us...> - 2009-08-09 04:50:19
|
Revision: 7437
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7437&view=rev
Author: leejjoon
Date: 2009-08-09 04:50:12 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
retrieve a sample image using cbook.get_sample_data function
Modified Paths:
--------------
trunk/matplotlib/examples/axes_grid/demo_axes_divider.py
trunk/matplotlib/examples/axes_grid/demo_axes_grid.py
trunk/matplotlib/examples/axes_grid/inset_locator_demo2.py
trunk/matplotlib/examples/axes_grid/simple_axesgrid2.py
trunk/matplotlib/examples/axes_grid/simple_rgb.py
Removed Paths:
-------------
trunk/matplotlib/lib/mpl_toolkits/axes_grid/demo_image.py
Modified: trunk/matplotlib/examples/axes_grid/demo_axes_divider.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/demo_axes_divider.py 2009-08-09 04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/examples/axes_grid/demo_axes_divider.py 2009-08-09 04:50:12 UTC (rev 7437)
@@ -1,7 +1,14 @@
import matplotlib.pyplot as plt
-from mpl_toolkits.axes_grid.demo_image import get_demo_image
-#import mpl_toolkits.imaging.axes_grid as imaging
+def get_demo_image():
+ import numpy as np
+ from matplotlib.cbook import get_sample_data
+ f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
+ z = np.load(f)
+ # z is a numpy array of 15x15
+ return z, (-3,4,-4,3)
+
+
def demo_simple_image(ax):
Z, extent = get_demo_image()
Modified: trunk/matplotlib/examples/axes_grid/demo_axes_grid.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/demo_axes_grid.py 2009-08-09 04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/examples/axes_grid/demo_axes_grid.py 2009-08-09 04:50:12 UTC (rev 7437)
@@ -1,7 +1,13 @@
import matplotlib.pyplot as plt
-from mpl_toolkits.axes_grid.demo_image import get_demo_image
from mpl_toolkits.axes_grid import AxesGrid
+def get_demo_image():
+ import numpy as np
+ from matplotlib.cbook import get_sample_data
+ f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
+ z = np.load(f)
+ # z is a numpy array of 15x15
+ return z, (-3,4,-4,3)
def demo_simple_grid(fig):
"""
Modified: trunk/matplotlib/examples/axes_grid/inset_locator_demo2.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/inset_locator_demo2.py 2009-08-09 04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/examples/axes_grid/inset_locator_demo2.py 2009-08-09 04:50:12 UTC (rev 7437)
@@ -5,7 +5,13 @@
import numpy as np
-from mpl_toolkits.axes_grid.demo_image import get_demo_image
+def get_demo_image():
+ from matplotlib.cbook import get_sample_data
+ import numpy as np
+ f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
+ z = np.load(f)
+ # z is a numpy array of 15x15
+ return z, (-3,4,-4,3)
fig = plt.figure(1, [5,4])
Modified: trunk/matplotlib/examples/axes_grid/simple_axesgrid2.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/simple_axesgrid2.py 2009-08-09 04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/examples/axes_grid/simple_axesgrid2.py 2009-08-09 04:50:12 UTC (rev 7437)
@@ -1,7 +1,14 @@
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid import AxesGrid
-from mpl_toolkits.axes_grid.demo_image import get_demo_image
+def get_demo_image():
+ import numpy as np
+ from matplotlib.cbook import get_sample_data
+ f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
+ z = np.load(f)
+ # z is a numpy array of 15x15
+ return z, (-3,4,-4,3)
+
F = plt.figure(1, (5.5, 3.5))
grid = AxesGrid(F, 111, # similar to subplot(111)
nrows_ncols = (1, 3),
Modified: trunk/matplotlib/examples/axes_grid/simple_rgb.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/simple_rgb.py 2009-08-09 04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/examples/axes_grid/simple_rgb.py 2009-08-09 04:50:12 UTC (rev 7437)
@@ -1,8 +1,15 @@
import matplotlib.pyplot as plt
-from mpl_toolkits.axes_grid.demo_image import get_demo_image
from mpl_toolkits.axes_grid.axes_rgb import RGBAxes
+def get_demo_image():
+ import numpy as np
+ from matplotlib.cbook import get_sample_data
+ f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
+ z = np.load(f)
+ # z is a numpy array of 15x15
+ return z, (-3,4,-4,3)
+
def get_rgb():
Z, extent = get_demo_image()
Deleted: trunk/matplotlib/lib/mpl_toolkits/axes_grid/demo_image.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/demo_image.py 2009-08-09 04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/demo_image.py 2009-08-09 04:50:12 UTC (rev 7437)
@@ -1,17 +0,0 @@
-import numpy as np
-
-def get_demo_image():
- # prepare image
- delta = 0.5
-
- extent = (-3,4,-4,3)
- x = np.arange(-3.0, 4.001, delta)
- y = np.arange(-4.0, 3.001, delta)
- X, Y = np.meshgrid(x, y)
- import matplotlib.mlab as mlab
- Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
- Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
- Z = (Z1 - Z2) * 10
-
- return Z, extent
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-08-09 04:34:16
|
Revision: 7436
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7436&view=rev
Author: leejjoon
Date: 2009-08-09 04:34:08 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
axes_grid data file added
Added Paths:
-----------
trunk/sample_data/axes_grid/
trunk/sample_data/axes_grid/bivariate_normal.npy
Added: trunk/sample_data/axes_grid/bivariate_normal.npy
===================================================================
(Binary files differ)
Property changes on: trunk/sample_data/axes_grid/bivariate_normal.npy
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-08-08 21:11:34
|
Revision: 7435
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7435&view=rev
Author: leejjoon
Date: 2009-08-08 21:11:18 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
fix example demo_ribbon_box.py
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py
Modified: trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py 2009-08-08 18:24:52 UTC (rev 7434)
+++ trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py 2009-08-08 21:11:18 UTC (rev 7435)
@@ -64,13 +64,13 @@
):
BboxImage.__init__(self, bbox,
- cmap = None,
- norm = None,
- interpolation=None,
- origin=None,
- filternorm=1,
- filterrad=4.0,
- resample = False,
+ cmap = cmap,
+ norm = norm,
+ interpolation=interpolation,
+ origin=origin,
+ filternorm=filternorm,
+ filterrad=filterrad,
+ resample = resample,
**kwargs
)
@@ -115,7 +115,7 @@
for year, h, bc in zip(years, heights, box_colors):
bbox0 = Bbox.from_extents(year-0.4, 0., year+0.4, h)
bbox = TransformedBbox(bbox0, ax.transData)
- rb_patch = RibbonBoxImage(bbox, bc)
+ rb_patch = RibbonBoxImage(bbox, bc, interpolation="bicubic")
ax.add_artist(rb_patch)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-08-08 18:25:00
|
Revision: 7434
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7434&view=rev
Author: efiring
Date: 2009-08-08 18:24:52 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Merged revisions 7428-7433 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint
........
r7428 | jdh2358 | 2009-08-08 02:21:29 -1000 (Sat, 08 Aug 2009) | 1 line
clean up mplot3d examples: use pyplot noy pylab and numpy rather than list comps and python random module
........
r7429 | jdh2358 | 2009-08-08 03:53:24 -1000 (Sat, 08 Aug 2009) | 1 line
two new examples using a compund path for a histogram; one animated
........
r7430 | jdh2358 | 2009-08-08 03:58:52 -1000 (Sat, 08 Aug 2009) | 1 line
two new examples using a compund path for a histogram; one animated
........
r7431 | jdh2358 | 2009-08-08 05:10:08 -1000 (Sat, 08 Aug 2009) | 1 line
use a class helper method to make the compound path from polys
........
r7432 | jdh2358 | 2009-08-08 05:16:57 -1000 (Sat, 08 Aug 2009) | 1 line
simplify poly array in example
........
r7433 | efiring | 2009-08-08 08:16:01 -1000 (Sat, 08 Aug 2009) | 2 lines
Fix excessive line length in annotations.rst
........
Modified Paths:
--------------
trunk/matplotlib/doc/users/annotations.rst
trunk/matplotlib/examples/mplot3d/2dcollections3d_demo.py
trunk/matplotlib/examples/mplot3d/bars3d_demo.py
trunk/matplotlib/examples/mplot3d/contour3d_demo.py
trunk/matplotlib/examples/mplot3d/contour3d_demo2.py
trunk/matplotlib/examples/mplot3d/contourf3d_demo.py
trunk/matplotlib/examples/mplot3d/hist3d_demo.py
trunk/matplotlib/examples/mplot3d/lines3d_demo.py
trunk/matplotlib/examples/mplot3d/polys3d_demo.py
trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo2.py
trunk/matplotlib/examples/mplot3d/text3d_demo.py
trunk/matplotlib/examples/mplot3d/wire3d_demo.py
trunk/matplotlib/lib/matplotlib/path.py
Added Paths:
-----------
trunk/matplotlib/examples/animation/histogram_tkagg.py
trunk/matplotlib/examples/api/histogram_path_demo.py
Property Changed:
----------------
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
trunk/matplotlib/examples/misc/multiprocess.py
trunk/matplotlib/examples/mplot3d/contour3d_demo.py
trunk/matplotlib/examples/mplot3d/contourf3d_demo.py
trunk/matplotlib/examples/mplot3d/polys3d_demo.py
trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo.py
trunk/matplotlib/examples/mplot3d/wire3d_demo.py
trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7426
+ /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7433
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433
Property changes on: trunk/matplotlib/doc/pyplots/README
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424
+ /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/doc/users/annotations.rst
===================================================================
--- trunk/matplotlib/doc/users/annotations.rst 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/doc/users/annotations.rst 2009-08-08 18:24:52 UTC (rev 7434)
@@ -56,17 +56,20 @@
properties in the optional keyword argument ``arrowprops``.
-==================== ===========================================================================
+==================== =====================================================
``arrowprops`` key description
-==================== ===========================================================================
+==================== =====================================================
width the width of the arrow in points
frac the fraction of the arrow length occupied by the head
headwidth the width of the base of the arrow head in points
-shrink move the tip and base some percent away from the annotated point and text
-\*\*kwargs any key for :class:`matplotlib.patches.Polygon`, eg ``facecolor``
-==================== ===========================================================================
+shrink move the tip and base some percent away from
+ the annotated point and text
+\*\*kwargs any key for :class:`matplotlib.patches.Polygon`,
+ e.g. ``facecolor``
+==================== =====================================================
+
In the example below, the ``xy`` point is in native coordinates
(``xycoords`` defaults to 'data'). For a polar axes, this is in
(theta, radius) space. The text in this example is placed in the
@@ -78,4 +81,7 @@
.. plot:: pyplots/annotation_polar.py
:include-source:
-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`.
+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`.
+
Copied: trunk/matplotlib/examples/animation/histogram_tkagg.py (from rev 7433, branches/v0_99_maint/examples/animation/histogram_tkagg.py)
===================================================================
--- trunk/matplotlib/examples/animation/histogram_tkagg.py (rev 0)
+++ trunk/matplotlib/examples/animation/histogram_tkagg.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -0,0 +1,70 @@
+"""
+This example shows how to use a path patch to draw a bunch of
+rectangles for an animated histogram
+"""
+import time
+import numpy as np
+import matplotlib
+matplotlib.use('TkAgg') # do this before importing pylab
+
+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)
+
+# here comes the tricky part -- we have to set up the vertex and path
+# codes arrays using moveto, lineto and closepoly
+
+# for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the
+# CLOSEPOLY; the vert 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
+
+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())
+
+def animate():
+ if animate.cnt>=100:
+ return
+
+ animate.cnt += 1
+ # simulate new data coming in
+ data = np.random.randn(1000)
+ n, bins = np.histogram(data, 100)
+ top = bottom + n
+ verts[1::5,1] = top
+ verts[2::5,1] = top
+ fig.canvas.draw()
+ fig.canvas.manager.window.after(100, animate)
+animate.cnt = 0
+fig.canvas.manager.window.after(100, animate)
+plt.show()
Copied: trunk/matplotlib/examples/api/histogram_path_demo.py (from rev 7433, branches/v0_99_maint/examples/api/histogram_path_demo.py)
===================================================================
--- trunk/matplotlib/examples/api/histogram_path_demo.py (rev 0)
+++ trunk/matplotlib/examples/api/histogram_path_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -0,0 +1,47 @@
+"""
+This example shows how to use a path patch to draw a bunch of
+rectangles. The technique of using lots of Rectangle instances, or
+the faster method of using PolyCollections, were implemented before we
+had proper paths with moveto/lineto, closepoly etc in mpl. Now that
+we have them, we can draw collections of regularly shaped objects with
+homogeous properties more efficiently with a PathCollection. This
+example makes a histogram -- its more work to set up the vertex arrays
+at the outset, but it should be much faster for large numbers of
+objects
+"""
+
+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, 50)
+
+# 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
+
+
+# we need a (numrects x numsides x 2) numpy array for the path helper
+# function to build a compound path
+XY = np.array([[left,left,right,right], [bottom,top,top,bottom]]).T
+
+# get the Path object
+barpath = path.Path.make_compound_path_from_polys(XY)
+
+# make a patch out of it
+patch = patches.PathPatch(barpath, facecolor='blue', edgecolor='gray', alpha=0.8)
+ax.add_patch(patch)
+
+# update the view limits
+ax.set_xlim(left[0], right[-1])
+ax.set_ylim(bottom.min(), top.max())
+
+plt.show()
Property changes on: trunk/matplotlib/examples/misc/multiprocess.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/misc/log.py:5753-5771
/branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/misc/log.py:5753-5771
/branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/examples/mplot3d/2dcollections3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/2dcollections3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/2dcollections3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,8 +1,8 @@
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
-import pylab
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
x = np.linspace(0, 1, 100)
@@ -20,5 +20,5 @@
ax.set_ylim3d(0, 1)
ax.set_zlim3d(0, 1)
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/bars3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/bars3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/bars3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,20 +1,17 @@
from mpl_toolkits.mplot3d import Axes3D
-from matplotlib.collections import PolyCollection
-from matplotlib.colors import colorConverter
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
- ys = [random.random() for x in xs]
+ ys = np.random.rand(20)
ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/contour3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/contour3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/contour3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z)
ax.clabel(cset, fontsize=9, inline=1)
-pylab.show()
+plt.show()
Property changes on: trunk/matplotlib/examples/mplot3d/contour3d_demo.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/examples/mplot3d/contour3d_demo2.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/contour3d_demo2.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/contour3d_demo2.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, 16, extend3d=True)
ax.clabel(cset, fontsize=9, inline=1)
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/contourf3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/contourf3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/contourf3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contourf(X, Y, Z)
ax.clabel(cset, fontsize=9, inline=1)
-pylab.show()
+plt.show()
Property changes on: trunk/matplotlib/examples/mplot3d/contourf3d_demo.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/examples/mplot3d/hist3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/hist3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/hist3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,27 +1,22 @@
from mpl_toolkits.mplot3d import Axes3D
-from matplotlib.collections import PolyCollection
-from matplotlib.colors import colorConverter
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
-x = np.random.rand(100) * 4
-y = np.random.rand(100) * 4
+x, y = np.random.rand(2, 100) * 4
hist, xedges, yedges = np.histogram2d(x, y, bins=4)
elements = (len(xedges) - 1) * (len(yedges) - 1)
-xpos, ypos = np.meshgrid(
- [xedges[i] + 0.25 for i in range(len(xedges) - 1)],
- [yedges[i] + 0.25 for i in range(len(yedges) - 1)])
+xpos, ypos = np.meshgrid(xedges[:-1]+0.25, yedges[:-1]+0.25)
+
xpos = xpos.flatten()
ypos = ypos.flatten()
-zpos = [0] * elements
-dx = [0.5] * elements
-dy = [0.5] * elements
+zpos = np.zeros(elements)
+dx = 0.5 * np.ones_like(zpos)
+dy = dx.copy()
dz = hist.flatten()
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b')
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/lines3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/lines3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/lines3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,11 +1,11 @@
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
-import pylab
+import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
@@ -15,5 +15,5 @@
ax.plot(x, y, z, label='parametric curve')
ax.legend()
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/polys3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/polys3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/polys3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,11 +1,10 @@
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
@@ -14,7 +13,7 @@
verts = []
zs = [0.0, 1.0, 2.0, 3.0]
for z in zs:
- ys = [random.random() for x in xs]
+ ys = np.random.rand(len(xs))
ys[0], ys[-1] = 0, 0
verts.append(zip(xs, ys))
@@ -27,5 +26,5 @@
ax.set_ylim3d(-1, 4)
ax.set_zlim3d(0, 1)
-pylab.show()
+plt.show()
Property changes on: trunk/matplotlib/examples/mplot3d/polys3d_demo.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/scatter3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/scatter3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,21 +1,23 @@
+import numpy as np
from mpl_toolkits.mplot3d import Axes3D
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+
+def randrange(n, vmin, vmax):
+ return (vmax-vmin)*np.random.rand(n) + vmin
+
+fig = plt.figure()
ax = Axes3D(fig)
n = 100
for c, zl, zh in [('r', -50, -25), ('b', -30, -5)]:
- xs, ys, zs = zip(*
- [(random.randrange(23, 32),
- random.randrange(100),
- random.randrange(zl, zh)
- ) for i in range(n)])
+ xs = randrange(n, 23, 32)
+ ys = randrange(n, 0, 100)
+ zs = randrange(n, zl, zh)
ax.scatter(xs, ys, zs, c=c)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
-pylab.show()
+plt.show()
Property changes on: trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/examples/mplot3d/surface3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/surface3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/surface3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,10 +1,9 @@
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
@@ -13,5 +12,5 @@
Z = np.sin(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
-pylab.show()
+plt.show()
Property changes on: trunk/matplotlib/examples/mplot3d/surface3d_demo.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/examples/mplot3d/surface3d_demo2.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/surface3d_demo2.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/surface3d_demo2.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,9 +1,8 @@
from mpl_toolkits.mplot3d import Axes3D
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
u = np.linspace(0, 2 * np.pi, 100)
@@ -14,5 +13,5 @@
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b')
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/text3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/text3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/text3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,8 +1,7 @@
from mpl_toolkits.mplot3d import Axes3D
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
zdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1))
@@ -22,5 +21,5 @@
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
-pylab.show()
+plt.show()
Modified: trunk/matplotlib/examples/mplot3d/wire3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/wire3d_demo.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/examples/mplot3d/wire3d_demo.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
-pylab.show()
+plt.show()
Property changes on: trunk/matplotlib/examples/mplot3d/wire3d_demo.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771
/branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080
/branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py 2009-08-08 18:16:01 UTC (rev 7433)
+++ trunk/matplotlib/lib/matplotlib/path.py 2009-08-08 18:24:52 UTC (rev 7434)
@@ -129,6 +129,34 @@
self._interpolation_steps = _interpolation_steps
@classmethod
+ def make_compound_path_from_polys(cls, XY):
+ """
+ (static method) Make a compound path object to draw a number
+ of polygons with equal numbers of sides XY is a (numpolys x
+ numsides x 2) numpy array of vertices. Return object is a
+ :class:`Path`
+
+ .. plot:: mpl_examples/api/histogram_path_demo.py
+
+ """
+
+ # for each poly: 1 for the MOVETO, (numsides-1) for the LINETO, 1 for the
+ # CLOSEPOLY; the vert for the closepoly is ignored but we still need
+ # it to keep the codes aligned with the vertices
+ numpolys, numsides, two = XY.shape
+ assert(two==2)
+ stride = numsides + 1
+ nverts = numpolys * stride
+ verts = np.zeros((nverts, 2))
+ codes = np.ones(nverts, int) * cls.LINETO
+ codes[0::stride] = cls.MOVETO
+ codes[numsides::stride] = cls.CLOSEPOLY
+ for i in range(numsides):
+ verts[i::stride] = XY[:,i]
+
+ return cls(verts, codes)
+
+ @classmethod
def make_compound_path(cls, *args):
"""
(staticmethod) Make a compound path from a list of Path
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424
+ /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-08-08 18:16:07
|
Revision: 7433
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7433&view=rev
Author: efiring
Date: 2009-08-08 18:16:01 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Fix excessive line length in annotations.rst
Modified Paths:
--------------
branches/v0_99_maint/doc/users/annotations.rst
Modified: branches/v0_99_maint/doc/users/annotations.rst
===================================================================
--- branches/v0_99_maint/doc/users/annotations.rst 2009-08-08 15:16:57 UTC (rev 7432)
+++ branches/v0_99_maint/doc/users/annotations.rst 2009-08-08 18:16:01 UTC (rev 7433)
@@ -56,17 +56,20 @@
properties in the optional keyword argument ``arrowprops``.
-==================== ===========================================================================
+==================== =====================================================
``arrowprops`` key description
-==================== ===========================================================================
+==================== =====================================================
width the width of the arrow in points
frac the fraction of the arrow length occupied by the head
headwidth the width of the base of the arrow head in points
-shrink move the tip and base some percent away from the annotated point and text
-\*\*kwargs any key for :class:`matplotlib.patches.Polygon`, eg ``facecolor``
-==================== ===========================================================================
+shrink move the tip and base some percent away from
+ the annotated point and text
+\*\*kwargs any key for :class:`matplotlib.patches.Polygon`,
+ e.g. ``facecolor``
+==================== =====================================================
+
In the example below, the ``xy`` point is in native coordinates
(``xycoords`` defaults to 'data'). For a polar axes, this is in
(theta, radius) space. The text in this example is placed in the
@@ -78,4 +81,7 @@
.. plot:: pyplots/annotation_polar.py
:include-source:
-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`.
+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`.
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 15:17:05
|
Revision: 7432
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7432&view=rev
Author: jdh2358
Date: 2009-08-08 15:16:57 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
simplify poly array in example
Modified Paths:
--------------
branches/v0_99_maint/examples/api/histogram_path_demo.py
Modified: branches/v0_99_maint/examples/api/histogram_path_demo.py
===================================================================
--- branches/v0_99_maint/examples/api/histogram_path_demo.py 2009-08-08 15:10:08 UTC (rev 7431)
+++ branches/v0_99_maint/examples/api/histogram_path_demo.py 2009-08-08 15:16:57 UTC (rev 7432)
@@ -22,34 +22,25 @@
data = np.random.randn(1000)
n, bins = np.histogram(data, 50)
-
# 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)
-XY = np.zeros((nrects, 4, 2))
-XY[:,0,0] = left
-XY[:,0,1] = bottom
-XY[:,1,0] = left
-XY[:,1,1] = top
+# we need a (numrects x numsides x 2) numpy array for the path helper
+# function to build a compound path
+XY = np.array([[left,left,right,right], [bottom,top,top,bottom]]).T
-XY[:,2,0] = right
-XY[:,2,1] = top
-
-XY[:,3,0] = right
-XY[:,3,1] = bottom
-
-
-
+# get the Path object
barpath = path.Path.make_compound_path_from_polys(XY)
-print barpath.codes[:7], barpath.codes[-7:]
+
+# make a patch out of it
patch = patches.PathPatch(barpath, facecolor='blue', edgecolor='gray', alpha=0.8)
ax.add_patch(patch)
+# update the view limits
ax.set_xlim(left[0], right[-1])
ax.set_ylim(bottom.min(), top.max())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 15:10:17
|
Revision: 7431
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7431&view=rev
Author: jdh2358
Date: 2009-08-08 15:10:08 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
use a class helper method to make the compound path from polys
Modified Paths:
--------------
branches/v0_99_maint/examples/animation/histogram_tkagg.py
branches/v0_99_maint/examples/api/histogram_path_demo.py
branches/v0_99_maint/lib/matplotlib/path.py
Modified: branches/v0_99_maint/examples/animation/histogram_tkagg.py
===================================================================
--- branches/v0_99_maint/examples/animation/histogram_tkagg.py 2009-08-08 13:58:52 UTC (rev 7430)
+++ branches/v0_99_maint/examples/animation/histogram_tkagg.py 2009-08-08 15:10:08 UTC (rev 7431)
@@ -2,6 +2,7 @@
This example shows how to use a path patch to draw a bunch of
rectangles for an animated histogram
"""
+import time
import numpy as np
import matplotlib
matplotlib.use('TkAgg') # do this before importing pylab
@@ -52,6 +53,10 @@
ax.set_ylim(bottom.min(), top.max())
def animate():
+ if animate.cnt>=100:
+ return
+
+ animate.cnt += 1
# simulate new data coming in
data = np.random.randn(1000)
n, bins = np.histogram(data, 100)
@@ -59,11 +64,7 @@
verts[1::5,1] = top
verts[2::5,1] = top
fig.canvas.draw()
-
-def run():
- for i in range(100):
- fig.canvas.manager.window.after(100, animate)
-
-
-fig.canvas.manager.window.after(100, run)
+ fig.canvas.manager.window.after(100, animate)
+animate.cnt = 0
+fig.canvas.manager.window.after(100, animate)
plt.show()
Modified: branches/v0_99_maint/examples/api/histogram_path_demo.py
===================================================================
--- branches/v0_99_maint/examples/api/histogram_path_demo.py 2009-08-08 13:58:52 UTC (rev 7430)
+++ branches/v0_99_maint/examples/api/histogram_path_demo.py 2009-08-08 15:10:08 UTC (rev 7431)
@@ -20,8 +20,9 @@
# histogram our data with numpy
data = np.random.randn(1000)
-n, bins = np.histogram(data, 100)
+n, bins = np.histogram(data, 50)
+
# get the corners of the rectangles for the histogram
left = np.array(bins[:-1])
right = np.array(bins[1:])
@@ -29,28 +30,24 @@
top = bottom + n
nrects = len(left)
-# here comes the tricky part -- we have to set up the vertex and path
-# codes arrays using moveto, lineto and closepoly
+XY = np.zeros((nrects, 4, 2))
+XY[:,0,0] = left
+XY[:,0,1] = bottom
-# for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the
-# CLOSEPOLY; the vert 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
+XY[:,1,0] = left
+XY[:,1,1] = top
-barpath = path.Path(verts, codes)
-patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5)
+XY[:,2,0] = right
+XY[:,2,1] = top
+
+XY[:,3,0] = right
+XY[:,3,1] = bottom
+
+
+
+barpath = path.Path.make_compound_path_from_polys(XY)
+print barpath.codes[:7], barpath.codes[-7:]
+patch = patches.PathPatch(barpath, facecolor='blue', edgecolor='gray', alpha=0.8)
ax.add_patch(patch)
ax.set_xlim(left[0], right[-1])
Modified: branches/v0_99_maint/lib/matplotlib/path.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/path.py 2009-08-08 13:58:52 UTC (rev 7430)
+++ branches/v0_99_maint/lib/matplotlib/path.py 2009-08-08 15:10:08 UTC (rev 7431)
@@ -129,6 +129,34 @@
self._interpolation_steps = _interpolation_steps
@classmethod
+ def make_compound_path_from_polys(cls, XY):
+ """
+ (static method) Make a compound path object to draw a number
+ of polygons with equal numbers of sides XY is a (numpolys x
+ numsides x 2) numpy array of vertices. Return object is a
+ :class:`Path`
+
+ .. plot:: mpl_examples/api/histogram_path_demo.py
+
+ """
+
+ # for each poly: 1 for the MOVETO, (numsides-1) for the LINETO, 1 for the
+ # CLOSEPOLY; the vert for the closepoly is ignored but we still need
+ # it to keep the codes aligned with the vertices
+ numpolys, numsides, two = XY.shape
+ assert(two==2)
+ stride = numsides + 1
+ nverts = numpolys * stride
+ verts = np.zeros((nverts, 2))
+ codes = np.ones(nverts, int) * cls.LINETO
+ codes[0::stride] = cls.MOVETO
+ codes[numsides::stride] = cls.CLOSEPOLY
+ for i in range(numsides):
+ verts[i::stride] = XY[:,i]
+
+ return cls(verts, codes)
+
+ @classmethod
def make_compound_path(cls, *args):
"""
(staticmethod) Make a compound path from a list of Path
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 13:58:59
|
Revision: 7430
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7430&view=rev
Author: jdh2358
Date: 2009-08-08 13:58:52 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
two new examples using a compund path for a histogram; one animated
Modified Paths:
--------------
branches/v0_99_maint/examples/animation/histogram_tkagg.py
Modified: branches/v0_99_maint/examples/animation/histogram_tkagg.py
===================================================================
--- branches/v0_99_maint/examples/animation/histogram_tkagg.py 2009-08-08 13:53:24 UTC (rev 7429)
+++ branches/v0_99_maint/examples/animation/histogram_tkagg.py 2009-08-08 13:58:52 UTC (rev 7430)
@@ -1,15 +1,7 @@
"""
This example shows how to use a path patch to draw a bunch of
-rectangles. The technique of using lots of Rectangle instances, or
-the faster method of using PolyCollections, were implemented before we
-had proper paths with moveto/lineto, closepoly etc in mpl. Now that
-we have them, we can draw collections of regularly shaped objects with
-homogeous properties more efficiently with a PathCollection. This
-example makes a histogram -- its more work to set up the vertex arrays
-at the outset, but it should be much faster for large numbers of
-objects
+rectangles for an animated histogram
"""
-import time
import numpy as np
import matplotlib
matplotlib.use('TkAgg') # do this before importing pylab
@@ -60,7 +52,6 @@
ax.set_ylim(bottom.min(), top.max())
def animate():
- tstart = time.time() # for profiling
# simulate new data coming in
data = np.random.randn(1000)
n, bins = np.histogram(data, 100)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 13:53:35
|
Revision: 7429
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7429&view=rev
Author: jdh2358
Date: 2009-08-08 13:53:24 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
two new examples using a compund path for a histogram; one animated
Added Paths:
-----------
branches/v0_99_maint/examples/animation/histogram_tkagg.py
branches/v0_99_maint/examples/api/histogram_path_demo.py
Added: branches/v0_99_maint/examples/animation/histogram_tkagg.py
===================================================================
--- branches/v0_99_maint/examples/animation/histogram_tkagg.py (rev 0)
+++ branches/v0_99_maint/examples/animation/histogram_tkagg.py 2009-08-08 13:53:24 UTC (rev 7429)
@@ -0,0 +1,78 @@
+"""
+This example shows how to use a path patch to draw a bunch of
+rectangles. The technique of using lots of Rectangle instances, or
+the faster method of using PolyCollections, were implemented before we
+had proper paths with moveto/lineto, closepoly etc in mpl. Now that
+we have them, we can draw collections of regularly shaped objects with
+homogeous properties more efficiently with a PathCollection. This
+example makes a histogram -- its more work to set up the vertex arrays
+at the outset, but it should be much faster for large numbers of
+objects
+"""
+import time
+import numpy as np
+import matplotlib
+matplotlib.use('TkAgg') # do this before importing pylab
+
+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)
+
+# here comes the tricky part -- we have to set up the vertex and path
+# codes arrays using moveto, lineto and closepoly
+
+# for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the
+# CLOSEPOLY; the vert 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
+
+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())
+
+def animate():
+ tstart = time.time() # for profiling
+ # simulate new data coming in
+ data = np.random.randn(1000)
+ n, bins = np.histogram(data, 100)
+ top = bottom + n
+ verts[1::5,1] = top
+ verts[2::5,1] = top
+ fig.canvas.draw()
+
+def run():
+ for i in range(100):
+ fig.canvas.manager.window.after(100, animate)
+
+
+fig.canvas.manager.window.after(100, run)
+plt.show()
Added: branches/v0_99_maint/examples/api/histogram_path_demo.py
===================================================================
--- branches/v0_99_maint/examples/api/histogram_path_demo.py (rev 0)
+++ branches/v0_99_maint/examples/api/histogram_path_demo.py 2009-08-08 13:53:24 UTC (rev 7429)
@@ -0,0 +1,59 @@
+"""
+This example shows how to use a path patch to draw a bunch of
+rectangles. The technique of using lots of Rectangle instances, or
+the faster method of using PolyCollections, were implemented before we
+had proper paths with moveto/lineto, closepoly etc in mpl. Now that
+we have them, we can draw collections of regularly shaped objects with
+homogeous properties more efficiently with a PathCollection. This
+example makes a histogram -- its more work to set up the vertex arrays
+at the outset, but it should be much faster for large numbers of
+objects
+"""
+
+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)
+
+# here comes the tricky part -- we have to set up the vertex and path
+# codes arrays using moveto, lineto and closepoly
+
+# for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the
+# CLOSEPOLY; the vert 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
+
+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()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 12:21:36
|
Revision: 7428
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7428&view=rev
Author: jdh2358
Date: 2009-08-08 12:21:29 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
clean up mplot3d examples: use pyplot noy pylab and numpy rather than list comps and python random module
Modified Paths:
--------------
branches/v0_99_maint/examples/mplot3d/2dcollections3d_demo.py
branches/v0_99_maint/examples/mplot3d/bars3d_demo.py
branches/v0_99_maint/examples/mplot3d/contour3d_demo.py
branches/v0_99_maint/examples/mplot3d/contour3d_demo2.py
branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py
branches/v0_99_maint/examples/mplot3d/hist3d_demo.py
branches/v0_99_maint/examples/mplot3d/lines3d_demo.py
branches/v0_99_maint/examples/mplot3d/polys3d_demo.py
branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py
branches/v0_99_maint/examples/mplot3d/surface3d_demo.py
branches/v0_99_maint/examples/mplot3d/surface3d_demo2.py
branches/v0_99_maint/examples/mplot3d/text3d_demo.py
branches/v0_99_maint/examples/mplot3d/wire3d_demo.py
Modified: branches/v0_99_maint/examples/mplot3d/2dcollections3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/2dcollections3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/2dcollections3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,8 +1,8 @@
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
-import pylab
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
x = np.linspace(0, 1, 100)
@@ -20,5 +20,5 @@
ax.set_ylim3d(0, 1)
ax.set_zlim3d(0, 1)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/bars3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/bars3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/bars3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,20 +1,17 @@
from mpl_toolkits.mplot3d import Axes3D
-from matplotlib.collections import PolyCollection
-from matplotlib.colors import colorConverter
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
- ys = [random.random() for x in xs]
+ ys = np.random.rand(20)
ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/contour3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/contour3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/contour3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z)
ax.clabel(cset, fontsize=9, inline=1)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/contour3d_demo2.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/contour3d_demo2.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/contour3d_demo2.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, 16, extend3d=True)
ax.clabel(cset, fontsize=9, inline=1)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contourf(X, Y, Z)
ax.clabel(cset, fontsize=9, inline=1)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/hist3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/hist3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/hist3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,27 +1,22 @@
from mpl_toolkits.mplot3d import Axes3D
-from matplotlib.collections import PolyCollection
-from matplotlib.colors import colorConverter
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
-x = np.random.rand(100) * 4
-y = np.random.rand(100) * 4
+x, y = np.random.rand(2, 100) * 4
hist, xedges, yedges = np.histogram2d(x, y, bins=4)
elements = (len(xedges) - 1) * (len(yedges) - 1)
-xpos, ypos = np.meshgrid(
- [xedges[i] + 0.25 for i in range(len(xedges) - 1)],
- [yedges[i] + 0.25 for i in range(len(yedges) - 1)])
+xpos, ypos = np.meshgrid(xedges[:-1]+0.25, yedges[:-1]+0.25)
+
xpos = xpos.flatten()
ypos = ypos.flatten()
-zpos = [0] * elements
-dx = [0.5] * elements
-dy = [0.5] * elements
+zpos = np.zeros(elements)
+dx = 0.5 * np.ones_like(zpos)
+dy = dx.copy()
dz = hist.flatten()
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b')
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/lines3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/lines3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/lines3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,11 +1,11 @@
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
-import pylab
+import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
@@ -15,5 +15,5 @@
ax.plot(x, y, z, label='parametric curve')
ax.legend()
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/polys3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/polys3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/polys3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,11 +1,10 @@
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
@@ -14,7 +13,7 @@
verts = []
zs = [0.0, 1.0, 2.0, 3.0]
for z in zs:
- ys = [random.random() for x in xs]
+ ys = np.random.rand(len(xs))
ys[0], ys[-1] = 0, 0
verts.append(zip(xs, ys))
@@ -27,5 +26,5 @@
ax.set_ylim3d(-1, 4)
ax.set_zlim3d(0, 1)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,21 +1,23 @@
+import numpy as np
from mpl_toolkits.mplot3d import Axes3D
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+
+def randrange(n, vmin, vmax):
+ return (vmax-vmin)*np.random.rand(n) + vmin
+
+fig = plt.figure()
ax = Axes3D(fig)
n = 100
for c, zl, zh in [('r', -50, -25), ('b', -30, -5)]:
- xs, ys, zs = zip(*
- [(random.randrange(23, 32),
- random.randrange(100),
- random.randrange(zl, zh)
- ) for i in range(n)])
+ xs = randrange(n, 23, 32)
+ ys = randrange(n, 0, 100)
+ zs = randrange(n, zl, zh)
ax.scatter(xs, ys, zs, c=c)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/surface3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/surface3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/surface3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,10 +1,9 @@
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
@@ -13,5 +12,5 @@
Z = np.sin(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/surface3d_demo2.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/surface3d_demo2.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/surface3d_demo2.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,9 +1,8 @@
from mpl_toolkits.mplot3d import Axes3D
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
u = np.linspace(0, 2 * np.pi, 100)
@@ -14,5 +13,5 @@
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b')
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/text3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/text3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/text3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,8 +1,7 @@
from mpl_toolkits.mplot3d import Axes3D
-import pylab
-import random
+import matplotlib.pyplot as plt
-fig = pylab.figure()
+fig = plt.figure()
ax = Axes3D(fig)
zdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1))
@@ -22,5 +21,5 @@
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
-pylab.show()
+plt.show()
Modified: branches/v0_99_maint/examples/mplot3d/wire3d_demo.py
===================================================================
--- branches/v0_99_maint/examples/mplot3d/wire3d_demo.py 2009-08-08 11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/wire3d_demo.py 2009-08-08 12:21:29 UTC (rev 7428)
@@ -1,12 +1,11 @@
from mpl_toolkits.mplot3d import axes3d
-import pylab
-import random
+import matplotlib.pyplot as plt
import numpy as np
-fig = pylab.figure()
+fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
-pylab.show()
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 11:25:40
|
Revision: 7427
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7427&view=rev
Author: jdh2358
Date: 2009-08-08 11:25:32 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Merged revisions 7426 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint
........
r7426 | jdh2358 | 2009-08-08 06:00:41 -0500 (Sat, 08 Aug 2009) | 1 line
replace list comps w/ numpy in mplot3d
........
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/proj3d.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7424
+ /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7426
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-08-08 11:00:41 UTC (rev 7426)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-08-08 11:25:32 UTC (rev 7427)
@@ -92,6 +92,7 @@
def set_3d_properties(self, zs=0, zdir='z'):
xs = self.get_xdata()
ys = self.get_ydata()
+
try:
zs = float(zs)
zs = [zs for x in xs]
@@ -116,7 +117,7 @@
'''Convert a path to a 3D segment.'''
if not iterable(zs):
- zs = [zs] * len(path)
+ zs = np.ones(len(path)) * zs
seg = []
pathsegs = path.iter_segments(simplify=False, curves=False)
@@ -131,7 +132,7 @@
'''
if not iterable(zs):
- zs = [zs] * len(paths)
+ zs = np.ones(len(paths)) * zs
segments = []
for path, pathz in zip(paths, zs):
@@ -192,7 +193,8 @@
def set_3d_properties(self, verts, zs=0, zdir='z'):
if not iterable(zs):
- zs = [zs] * len(verts)
+ zs = np.ones(len(verts)) * zs
+
self._segment3d = [juggle_axes(x, y, z, zdir) \
for ((x, y), z) in zip(verts, zs)]
self._facecolor3d = Patch.get_facecolor(self)
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-08-08 11:00:41 UTC (rev 7426)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-08-08 11:25:32 UTC (rev 7427)
@@ -58,7 +58,7 @@
xticks=[], yticks=[], *args, **kwargs)
self.M = None
-
+
self._ready = 1
self.mouse_init()
self.create_axes()
@@ -184,7 +184,7 @@
def autoscale_view(self, scalex=True, scaley=True, scalez=True):
# This method looks at the rectanglular volume (see above)
# of data and decides how to scale the view portal to fit it.
-
+
self.set_top_view()
if not self._ready:
return
@@ -534,7 +534,7 @@
# Match length
if not cbook.iterable(zs):
- zs = [zs] * len(xs)
+ zs = np.ones(len(xs)) * zs
lines = Axes.plot(self, xs, ys, *args[argsi:], **kwargs)
for line in lines:
@@ -552,7 +552,7 @@
By default it will be colored in shades of a solid color,
but it also supports color mapping by supplying the *cmap*
argument.
-
+
========== ================================================
Argument Description
========== ================================================
@@ -648,7 +648,7 @@
shade = np.array(shade)
mask = ~np.isnan(shade)
- if len(shade[mask]) > 0:
+ if len(shade[mask]) > 0:
norm = Normalize(min(shade[mask]), max(shade[mask]))
color = color.copy()
color[3] = 1
@@ -679,7 +679,7 @@
rstride = kwargs.pop("rstride", 1)
cstride = kwargs.pop("cstride", 1)
-
+
had_data = self.has_data()
rows, cols = Z.shape
@@ -708,7 +708,7 @@
def _3d_extend_contour(self, cset, stride=5):
'''
- Extend a contour in 3D by creating
+ Extend a contour in 3D by creating
'''
levels = cset.levels
@@ -742,7 +742,7 @@
v1 = np.array(topverts[0][i1]) - np.array(topverts[0][i2])
v2 = np.array(topverts[0][i1]) - np.array(botverts[0][i1])
normals.append(np.cross(v1, v2))
-
+
colors = self._shade_colors(color, normals)
colors2 = self._shade_colors(color, normals)
polycol = art3d.Poly3DCollection(polyverts, facecolors=colors,
@@ -811,13 +811,13 @@
self.auto_scale_xyz(X, Y, Z, had_data)
return cset
-
+
contourf3D = contourf
def add_collection3d(self, col, zs=0, zdir='z'):
'''
Add a 3d collection object to the plot.
-
+
2D collection types are converted to a 3D version by
modifying the object and adding z coordinate information.
@@ -865,7 +865,7 @@
patches = Axes.scatter(self, xs, ys, *args, **kwargs)
if not cbook.iterable(zs):
is_2d = True
- zs = [zs] * len(xs)
+ zs = np.ones(len(xs)) * zs
else:
is_2d = False
art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir)
@@ -903,8 +903,9 @@
patches = Axes.bar(self, left, height, *args, **kwargs)
if not cbook.iterable(zs):
- zs = [zs] * len(left)
+ zs = np.ones(len(left))*zs
+
verts = []
verts_zs = []
for p, z in zip(patches, zs):
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py 2009-08-08 11:00:41 UTC (rev 7426)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py 2009-08-08 11:25:32 UTC (rev 7427)
@@ -22,6 +22,7 @@
def move_from_center(coord, centers, deltas, axmask=(True, True, True)):
'''Return a coordinate that is moved by "deltas" away from the center.'''
coord = copy.copy(coord)
+ #print coord, centers, deltas, axmask
for i in range(3):
if not axmask[i]:
continue
@@ -84,7 +85,7 @@
alpha=0.8,
facecolor=(1,1,1,0),
edgecolor=(1,1,1,0))
-
+
self.axes._set_artist_props(self.line)
self.axes._set_artist_props(self.pane)
self.gridlines = art3d.Line3DCollection([], )
@@ -141,7 +142,7 @@
# code from XAxis
majorTicks = self.get_major_ticks()
majorLocs = self.major.locator()
-
+
# filter locations here so that no extra grid lines are drawn
interval = self.get_view_interval()
majorLocs = [loc for loc in majorLocs if \
@@ -152,19 +153,20 @@
# Determine bounds
minx, maxx, miny, maxy, minz, maxz = self.axes.get_w_lims()
- mins = (minx, miny, minz)
- maxs = (maxx, maxy, maxz)
- centers = [(maxv + minv) / 2 for minv, maxv in zip(mins, maxs)]
- deltas = [(maxv - minv) / 12 for minv, maxv in zip(mins, maxs)]
- mins = [minv - delta / 4 for minv, delta in zip(mins, deltas)]
- maxs = [maxv + delta / 4 for maxv, delta in zip(maxs, deltas)]
+ mins = np.array((minx, miny, minz))
+ maxs = np.array((maxx, maxy, maxz))
+ centers = (maxs + mins) / 2.
+ deltas = (maxs - mins) / 12.
+ mins = mins - deltas / 4.
+ maxs = maxs + deltas / 4.
# Determine which planes should be visible by the avg z value
vals = mins[0], maxs[0], mins[1], maxs[1], mins[2], maxs[2]
tc = self.axes.tunit_cube(vals, renderer.M)
+ #raise RuntimeError('WTF: p1=%s'%p1)
avgz = [tc[p1][2] + tc[p2][2] + tc[p3][2] + tc[p4][2] for \
p1, p2, p3, p4 in self._PLANES]
- highs = [avgz[2*i] < avgz[2*i+1] for i in range(3)]
+ highs = np.array([avgz[2*i] < avgz[2*i+1] for i in range(3)])
# Draw plane
info = self._AXINFO[self.adir]
@@ -178,18 +180,14 @@
self.pane.draw(renderer)
# Determine grid lines
- minmax = []
- for i, val in enumerate(highs):
- if val:
- minmax.append(maxs[i])
- else:
- minmax.append(mins[i])
+ minmax = np.where(highs, maxs, mins)
# Draw main axis line
juggled = art3d.juggle_axes(0, 2, 1, self.adir)
- edgep1 = copy.copy(minmax)
+ edgep1 = minmax.copy()
edgep1[juggled[0]] = get_flip_min_max(edgep1, juggled[0], mins, maxs)
- edgep2 = copy.copy(edgep1)
+
+ edgep2 = edgep1.copy()
edgep2[juggled[1]] = get_flip_min_max(edgep2, juggled[1], mins, maxs)
pep = proj3d.proj_trans_points([edgep1, edgep2], renderer.M)
self.line.set_data((pep[0][0], pep[0][1]), (pep[1][0], pep[1][1]))
@@ -198,15 +196,17 @@
# Grid points where the planes meet
xyz0 = []
for val in majorLocs:
- coord = copy.copy(minmax)
+ coord = minmax.copy()
coord[index] = val
xyz0.append(coord)
# Draw labels
dy = pep[1][1] - pep[1][0]
dx = pep[0][1] - pep[0][0]
- lxyz = [(v1 + v2) / 2 for v1, v2 in zip(edgep1, edgep2)]
- labeldeltas = [1.3 * x for x in deltas]
+
+ lxyz = 0.5*(edgep1 + edgep2)
+
+ labeldeltas = 1.3 * deltas
lxyz = move_from_center(lxyz, centers, labeldeltas)
tlx, tly, tlz = proj3d.proj_transform(lxyz[0], lxyz[1], lxyz[2], \
renderer.M)
@@ -293,7 +293,7 @@
def get_data_interval(self):
'return the Interval instance for this axis data limits'
return self.axes.xy_dataLim.intervaly
-
+
class ZAxis(Axis):
def get_data_interval(self):
'return the Interval instance for this axis data limits'
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/proj3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/proj3d.py 2009-08-08 11:00:41 UTC (rev 7426)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/proj3d.py 2009-08-08 11:25:32 UTC (rev 7427)
@@ -10,15 +10,8 @@
import numpy as np
import numpy.linalg as linalg
-def cross(a, b):
- """
- Cross product of two vectors
- A x B = <Ay*Bz - Az*By, Az*Bx - Ax*Bz, Ax*By - Ay*Bx>
- a x b = [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1]
- """
- return np.array([a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], \
- a[0]*b[1] - a[1]*b[0]])
+
def line2d(p0, p1):
"""
Return 2D equation of line in the form ax+by+c = 0
@@ -130,9 +123,9 @@
## old
n = n / mod(n)
- u = cross(V, n)
+ u = np.cross(V, n)
u = u / mod(u)
- v = cross(n, u)
+ v = np.cross(n, u)
Mr = [[u[0],u[1],u[2],0],
[v[0],v[1],v[2],0],
[n[0],n[1],n[2],0],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-08 11:00:49
|
Revision: 7426
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7426&view=rev
Author: jdh2358
Date: 2009-08-08 11:00:41 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
replace list comps w/ numpy in mplot3d
Modified Paths:
--------------
branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py
branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axes3d.py
branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axis3d.py
branches/v0_99_maint/lib/mpl_toolkits/mplot3d/proj3d.py
Modified: branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py 2009-08-08 06:24:00 UTC (rev 7425)
+++ branches/v0_99_maint/lib/mpl_toolkits/mplot3d/art3d.py 2009-08-08 11:00:41 UTC (rev 7426)
@@ -92,6 +92,7 @@
def set_3d_properties(self, zs=0, zdir='z'):
xs = self.get_xdata()
ys = self.get_ydata()
+
try:
zs = float(zs)
zs = [zs for x in xs]
@@ -116,7 +117,7 @@
'''Convert a path to a 3D segment.'''
if not iterable(zs):
- zs = [zs] * len(path)
+ zs = np.ones(len(path)) * zs
seg = []
pathsegs = path.iter_segments(simplify=False, curves=False)
@@ -131,7 +132,7 @@
'''
if not iterable(zs):
- zs = [zs] * len(paths)
+ zs = np.ones(len(paths)) * zs
segments = []
for path, pathz in zip(paths, zs):
@@ -192,7 +193,8 @@
def set_3d_properties(self, verts, zs=0, zdir='z'):
if not iterable(zs):
- zs = [zs] * len(verts)
+ zs = np.ones(len(verts)) * zs
+
self._segment3d = [juggle_axes(x, y, z, zdir) \
for ((x, y), z) in zip(verts, zs)]
self._facecolor3d = Patch.get_facecolor(self)
Modified: branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axes3d.py 2009-08-08 06:24:00 UTC (rev 7425)
+++ branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axes3d.py 2009-08-08 11:00:41 UTC (rev 7426)
@@ -58,7 +58,7 @@
xticks=[], yticks=[], *args, **kwargs)
self.M = None
-
+
self._ready = 1
self.mouse_init()
self.create_axes()
@@ -184,7 +184,7 @@
def autoscale_view(self, scalex=True, scaley=True, scalez=True):
# This method looks at the rectanglular volume (see above)
# of data and decides how to scale the view portal to fit it.
-
+
self.set_top_view()
if not self._ready:
return
@@ -534,7 +534,7 @@
# Match length
if not cbook.iterable(zs):
- zs = [zs] * len(xs)
+ zs = np.ones(len(xs)) * zs
lines = Axes.plot(self, xs, ys, *args[argsi:], **kwargs)
for line in lines:
@@ -552,7 +552,7 @@
By default it will be colored in shades of a solid color,
but it also supports color mapping by supplying the *cmap*
argument.
-
+
========== ================================================
Argument Description
========== ================================================
@@ -648,7 +648,7 @@
shade = np.array(shade)
mask = ~np.isnan(shade)
- if len(shade[mask]) > 0:
+ if len(shade[mask]) > 0:
norm = Normalize(min(shade[mask]), max(shade[mask]))
color = color.copy()
color[3] = 1
@@ -679,7 +679,7 @@
rstride = kwargs.pop("rstride", 1)
cstride = kwargs.pop("cstride", 1)
-
+
had_data = self.has_data()
rows, cols = Z.shape
@@ -708,7 +708,7 @@
def _3d_extend_contour(self, cset, stride=5):
'''
- Extend a contour in 3D by creating
+ Extend a contour in 3D by creating
'''
levels = cset.levels
@@ -742,7 +742,7 @@
v1 = np.array(topverts[0][i1]) - np.array(topverts[0][i2])
v2 = np.array(topverts[0][i1]) - np.array(botverts[0][i1])
normals.append(np.cross(v1, v2))
-
+
colors = self._shade_colors(color, normals)
colors2 = self._shade_colors(color, normals)
polycol = art3d.Poly3DCollection(polyverts, facecolors=colors,
@@ -811,13 +811,13 @@
self.auto_scale_xyz(X, Y, Z, had_data)
return cset
-
+
contourf3D = contourf
def add_collection3d(self, col, zs=0, zdir='z'):
'''
Add a 3d collection object to the plot.
-
+
2D collection types are converted to a 3D version by
modifying the object and adding z coordinate information.
@@ -865,7 +865,7 @@
patches = Axes.scatter(self, xs, ys, *args, **kwargs)
if not cbook.iterable(zs):
is_2d = True
- zs = [zs] * len(xs)
+ zs = np.ones(len(xs)) * zs
else:
is_2d = False
art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir)
@@ -903,8 +903,9 @@
patches = Axes.bar(self, left, height, *args, **kwargs)
if not cbook.iterable(zs):
- zs = [zs] * len(left)
+ zs = np.ones(len(left))*zs
+
verts = []
verts_zs = []
for p, z in zip(patches, zs):
Modified: branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axis3d.py
===================================================================
--- branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axis3d.py 2009-08-08 06:24:00 UTC (rev 7425)
+++ branches/v0_99_maint/lib/mpl_toolkits/mplot3d/axis3d.py 2009-08-08 11:00:41 UTC (rev 7426)
@@ -22,6 +22,7 @@
def move_from_center(coord, centers, deltas, axmask=(True, True, True)):
'''Return a coordinate that is moved by "deltas" away from the center.'''
coord = copy.copy(coord)
+ #print coord, centers, deltas, axmask
for i in range(3):
if not axmask[i]:
continue
@@ -84,7 +85,7 @@
alpha=0.8,
facecolor=(1,1,1,0),
edgecolor=(1,1,1,0))
-
+
self.axes._set_artist_props(self.line)
self.axes._set_artist_props(self.pane)
self.gridlines = art3d.Line3DCollection([], )
@@ -141,7 +142,7 @@
# code from XAxis
majorTicks = self.get_major_ticks()
majorLocs = self.major.locator()
-
+
# filter locations here so that no extra grid lines are drawn
interval = self.get_view_interval()
majorLocs = [loc for loc in majorLocs if \
@@ -152,19 +153,20 @@
# Determine bounds
minx, maxx, miny, maxy, minz, maxz = self.axes.get_w_lims()
- mins = (minx, miny, minz)
- maxs = (maxx, maxy, maxz)
- centers = [(maxv + minv) / 2 for minv, maxv in zip(mins, maxs)]
- deltas = [(maxv - minv) / 12 for minv, maxv in zip(mins, maxs)]
- mins = [minv - delta / 4 for minv, delta in zip(mins, deltas)]
- maxs = [maxv + delta / 4 for maxv, delta in zip(maxs, deltas)]
+ mins = np.array((minx, miny, minz))
+ maxs = np.array((maxx, maxy, maxz))
+ centers = (maxs + mins) / 2.
+ deltas = (maxs - mins) / 12.
+ mins = mins - deltas / 4.
+ maxs = maxs + deltas / 4.
# Determine which planes should be visible by the avg z value
vals = mins[0], maxs[0], mins[1], maxs[1], mins[2], maxs[2]
tc = self.axes.tunit_cube(vals, renderer.M)
+ #raise RuntimeError('WTF: p1=%s'%p1)
avgz = [tc[p1][2] + tc[p2][2] + tc[p3][2] + tc[p4][2] for \
p1, p2, p3, p4 in self._PLANES]
- highs = [avgz[2*i] < avgz[2*i+1] for i in range(3)]
+ highs = np.array([avgz[2*i] < avgz[2*i+1] for i in range(3)])
# Draw plane
info = self._AXINFO[self.adir]
@@ -178,18 +180,14 @@
self.pane.draw(renderer)
# Determine grid lines
- minmax = []
- for i, val in enumerate(highs):
- if val:
- minmax.append(maxs[i])
- else:
- minmax.append(mins[i])
+ minmax = np.where(highs, maxs, mins)
# Draw main axis line
juggled = art3d.juggle_axes(0, 2, 1, self.adir)
- edgep1 = copy.copy(minmax)
+ edgep1 = minmax.copy()
edgep1[juggled[0]] = get_flip_min_max(edgep1, juggled[0], mins, maxs)
- edgep2 = copy.copy(edgep1)
+
+ edgep2 = edgep1.copy()
edgep2[juggled[1]] = get_flip_min_max(edgep2, juggled[1], mins, maxs)
pep = proj3d.proj_trans_points([edgep1, edgep2], renderer.M)
self.line.set_data((pep[0][0], pep[0][1]), (pep[1][0], pep[1][1]))
@@ -198,15 +196,17 @@
# Grid points where the planes meet
xyz0 = []
for val in majorLocs:
- coord = copy.copy(minmax)
+ coord = minmax.copy()
coord[index] = val
xyz0.append(coord)
# Draw labels
dy = pep[1][1] - pep[1][0]
dx = pep[0][1] - pep[0][0]
- lxyz = [(v1 + v2) / 2 for v1, v2 in zip(edgep1, edgep2)]
- labeldeltas = [1.3 * x for x in deltas]
+
+ lxyz = 0.5*(edgep1 + edgep2)
+
+ labeldeltas = 1.3 * deltas
lxyz = move_from_center(lxyz, centers, labeldeltas)
tlx, tly, tlz = proj3d.proj_transform(lxyz[0], lxyz[1], lxyz[2], \
renderer.M)
@@ -293,7 +293,7 @@
def get_data_interval(self):
'return the Interval instance for this axis data limits'
return self.axes.xy_dataLim.intervaly
-
+
class ZAxis(Axis):
def get_data_interval(self):
'return the Interval instance for this axis data limits'
Modified: branches/v0_99_maint/lib/mpl_toolkits/mplot3d/proj3d.py
===================================================================
--- branches/v0_99_maint/lib/mpl_toolkits/mplot3d/proj3d.py 2009-08-08 06:24:00 UTC (rev 7425)
+++ branches/v0_99_maint/lib/mpl_toolkits/mplot3d/proj3d.py 2009-08-08 11:00:41 UTC (rev 7426)
@@ -10,15 +10,8 @@
import numpy as np
import numpy.linalg as linalg
-def cross(a, b):
- """
- Cross product of two vectors
- A x B = <Ay*Bz - Az*By, Az*Bx - Ax*Bz, Ax*By - Ay*Bx>
- a x b = [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1]
- """
- return np.array([a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], \
- a[0]*b[1] - a[1]*b[0]])
+
def line2d(p0, p1):
"""
Return 2D equation of line in the form ax+by+c = 0
@@ -130,9 +123,9 @@
## old
n = n / mod(n)
- u = cross(V, n)
+ u = np.cross(V, n)
u = u / mod(u)
- v = cross(n, u)
+ v = np.cross(n, u)
Mr = [[u[0],u[1],u[2],0],
[v[0],v[1],v[2],0],
[n[0],n[1],n[2],0],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-08-08 06:24:14
|
Revision: 7425
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7425&view=rev
Author: efiring
Date: 2009-08-08 06:24:00 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Merged revisions 7407,7409,7414,7416,7424 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint
........
r7407 | jdh2358 | 2009-08-06 08:51:58 -1000 (Thu, 06 Aug 2009) | 1 line
hide colorbar_doc a bit
........
r7409 | ryanmay | 2009-08-06 09:28:16 -1000 (Thu, 06 Aug 2009) | 1 line
Tweak solution for hiding colorbar_doc to sync with trunk.
........
r7414 | jdh2358 | 2009-08-07 00:15:04 -1000 (Fri, 07 Aug 2009) | 1 line
some doc fixes
........
r7416 | jdh2358 | 2009-08-07 05:40:56 -1000 (Fri, 07 Aug 2009) | 1 line
don't fail on window icon load
........
r7424 | efiring | 2009-08-07 20:07:06 -1000 (Fri, 07 Aug 2009) | 2 lines
Restore default colormap behavior: no color (alpha = 0) for masked data
........
Modified Paths:
--------------
trunk/matplotlib/doc/_templates/indexsidebar.html
trunk/matplotlib/doc/users/annotations.rst
trunk/matplotlib/doc/users/artists.rst
trunk/matplotlib/doc/users/credits.rst
trunk/matplotlib/doc/users/event_handling.rst
trunk/matplotlib/doc/users/pyplot_tutorial.rst
trunk/matplotlib/doc/users/screenshots.rst
trunk/matplotlib/doc/users/whats_new.rst
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
trunk/matplotlib/lib/matplotlib/colors.py
Property Changed:
----------------
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
trunk/matplotlib/examples/misc/multiprocess.py
trunk/matplotlib/examples/mplot3d/contour3d_demo.py
trunk/matplotlib/examples/mplot3d/contourf3d_demo.py
trunk/matplotlib/examples/mplot3d/polys3d_demo.py
trunk/matplotlib/examples/mplot3d/scatter3d_demo.py
trunk/matplotlib/examples/mplot3d/surface3d_demo.py
trunk/matplotlib/examples/mplot3d/wire3d_demo.py
trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7404
+ /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7424
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint:7338,7393,7395-7404
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint:7338,7393,7395-7404,7407-7424
Modified: trunk/matplotlib/doc/_templates/indexsidebar.html
===================================================================
--- trunk/matplotlib/doc/_templates/indexsidebar.html 2009-08-08 06:07:06 UTC (rev 7424)
+++ trunk/matplotlib/doc/_templates/indexsidebar.html 2009-08-08 06:24:00 UTC (rev 7425)
@@ -29,7 +29,7 @@
and join the matplotlib
mailing <a href="http://sourceforge.net/mail/?group_id=80706">lists</a>.
The <a href="{{ pathto('search') }}">search</a> tool searches all of
-the documentation, including full text search of almost 300 complete
+the documentation, including full text search of over 350 complete
examples which exercise almost every corner of matplotlib.</p>
<p>You can file bugs, patches and feature requests on the
Property changes on: trunk/matplotlib/doc/pyplots/README
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404
+ /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
/branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424
Modified: trunk/matplotlib/doc/users/annotations.rst
===================================================================
--- trunk/matplotlib/doc/users/annotations.rst 2009-08-08 06:07:06 UTC (rev 7424)
+++ trunk/matplotlib/doc/users/annotations.rst 2009-08-08 06:24:00 UTC (rev 7425)
@@ -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: trunk/matplotlib/doc/users/artists.rst
===================================================================
--- trunk/matplotlib/doc/users/artists.rst 2009-08-08 06:07:06 UTC (rev 7424)
+++ trunk/matplotlib/doc/users/artists.rst 2009-08-08 06:24:00 UTC (rev 7425)
@@ -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: trunk/matplotlib/doc/users/credits.rst
===================================================================
--- trunk/matplotlib/doc/users/credits.rst 2009-08-08 06:07:06 UTC (rev 7424)
+++ trunk/matplotlib/doc/users/credits.rst 2009-08-08 06:24:00 UTC (rev 7425)
@@ -16,9 +16,9 @@
Jeremy O'Donoghue
wrote the wx backend
-Andrew Straw
- provided much of the log scaling architecture, the fill command, PIL
- support for imshow, and provided many examples
+Andrew Straw provided much of the log scaling architecture, the fill
+ command, PIL support for imshow, and provided many examples. He
+ also wrote the support for dropped axis spines.
Charles Twardy
provided the impetus code for the legend class and has made
@@ -28,7 +28,6 @@
made many enhancements to errorbar to support x and y
errorbar plots, and added a number of new marker types to plot.
-
John Gill
wrote the table class and examples, helped with support for
auto-legend placement, and added support for legending scatter
@@ -133,7 +132,7 @@
most aspects of matplotlib.
Daishi Harada
- added support for "Dashed Text". See ` dashpointlabel.py
+ added support for "Dashed Text". See `dashpointlabel.py
<examples/pylab_examples/dashpointlabel.py>`_ and
:class:`~matplotlib.text.TextWithDash`.
@@ -147,11 +146,10 @@
Charlie Moad
- contributed work to matplotlib's Cocoa support and does the binary
- builds and releases.
+ contributed work to matplotlib's Cocoa support and has done a lot of work on the OSX and win32 binary releases.
-Jouni K. Seppaenen
- wrote the PDF backend.
+Jouni K. Seppaenen wrote the PDF backend and contributed numerous
+ fixes to the code, to tex support and to the get_sample_data handler
Paul Kienzle
improved the picking infrastruture for interactive plots, and with
@@ -171,4 +169,7 @@
matplotlib, and Jonathon Taylor and Reinier Heeres ported it to the
refactored transform trunk.
-
+Jae-Joon Lee implemented fancy arrows and boxes, rewrote the legend
+ support to handle multiple columns and fancy text boxes, wrote the
+ axes grid toolkit, and has made numerous contributions to the code
+ and documentation
\ No newline at end of file
Modified: trunk/matplotlib/doc/users/event_handling.rst
===================================================================
--- trunk/matplotlib/doc/users/event_handling.rst 2009-08-08 06:07:06 UTC (rev 7424)
+++ trunk/matplotlib/doc/users/event_handling.rst 2009-08-08 06:24:00 UTC (rev 7425)
@@ -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: trunk/matplotlib/doc/users/pyplot_tutorial.rst
===================================================================
--- trunk/matplotlib/doc/users/pyplot_tutorial.rst 2009-08-08 06:07:06 UTC (rev 7424)
+++ trunk/matplotlib/doc/users/pyplot_tutorial.rst 2009-08-08 06:24:00 UTC (rev 7425)
@@ -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 ``numr...
[truncated message content] |
|
From: <ef...@us...> - 2009-08-08 06:07:14
|
Revision: 7424
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7424&view=rev
Author: efiring
Date: 2009-08-08 06:07:06 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Restore default colormap behavior: no color (alpha = 0) for masked data
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/colors.py
Modified: branches/v0_99_maint/lib/matplotlib/colors.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/colors.py 2009-08-08 02:06:56 UTC (rev 7423)
+++ branches/v0_99_maint/lib/matplotlib/colors.py 2009-08-08 06:07:06 UTC (rev 7424)
@@ -488,7 +488,10 @@
if not self._isinit: self._init()
alpha = min(alpha, 1.0) # alpha must be between 0 and 1
alpha = max(alpha, 0.0)
- self._lut[:,-1] = alpha
+ self._lut[:-1,-1] = alpha # Don't assign global alpha to i_bad;
+ # it would defeat the purpose of the
+ # default behavior, which is to not
+ # show anything where data are missing.
mask_bad = None
if not cbook.iterable(X):
vtype = 'scalar'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-08-08 02:07:11
|
Revision: 7423
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7423&view=rev
Author: leejjoon
Date: 2009-08-08 02:06:56 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
BboxImage implemented and two examples added.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/image.py
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/demo_bboximage.py
trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-08-08 01:46:44 UTC (rev 7422)
+++ trunk/matplotlib/CHANGELOG 2009-08-08 02:06:56 UTC (rev 7423)
@@ -1,3 +1,6 @@
+2009-08-07 BboxImage implemented. Two examples, demo_bboximage.py and
+ demo_ribbon_box.py added. - JJL
+
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:
Added: trunk/matplotlib/examples/pylab_examples/demo_bboximage.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/demo_bboximage.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/demo_bboximage.py 2009-08-08 02:06:56 UTC (rev 7423)
@@ -0,0 +1,62 @@
+import matplotlib.pyplot as plt
+import numpy as np
+from matplotlib.image import BboxImage
+from matplotlib.transforms import Bbox, TransformedBbox
+
+if __name__ == "__main__":
+
+ fig = plt.figure(1)
+ ax = plt.subplot(121)
+
+ txt = ax.text(0.5, 0.5, "test", size=30, ha="center", color="w")
+ kwargs = dict()
+
+ bbox_image = BboxImage(txt.get_window_extent,
+ norm = None,
+ origin=None,
+ clip_on=False,
+ **kwargs
+ )
+ a = np.arange(256).reshape(1,256)/256.
+ bbox_image.set_data(a)
+ ax.add_artist(bbox_image)
+
+
+ ax = plt.subplot(122)
+ a = np.linspace(0, 1, 256).reshape(1,-1)
+ a = np.vstack((a,a))
+
+ maps = sorted(m for m in plt.cm.datad if not m.endswith("_r"))
+ #nmaps = len(maps) + 1
+
+ #fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99)
+
+ ncol = 2
+ nrow = len(maps)//ncol + 1
+
+ xpad_fraction = 0.3
+ dx = 1./(ncol + xpad_fraction*(ncol-1))
+
+ ypad_fraction = 0.3
+ dy = 1./(nrow + ypad_fraction*(nrow-1))
+
+ for i,m in enumerate(maps):
+ ix, iy = divmod(i, nrow)
+ #plt.figimage(a, 10, i*10, cmap=plt.get_cmap(m), origin='lower')
+ bbox0 = Bbox.from_bounds(ix*dx*(1+xpad_fraction),
+ 1.-iy*dy*(1+ypad_fraction)-dy,
+ dx, dy)
+ bbox = TransformedBbox(bbox0, ax.transAxes)
+
+ bbox_image = BboxImage(bbox,
+ cmap = plt.get_cmap(m),
+ norm = None,
+ origin=None,
+ **kwargs
+ )
+
+ bbox_image.set_data(a)
+ ax.add_artist(bbox_image)
+
+ plt.draw()
+ plt.show()
Added: trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/demo_ribbon_box.py 2009-08-08 02:06:56 UTC (rev 7423)
@@ -0,0 +1,140 @@
+import matplotlib.pyplot as plt
+import numpy as np
+from matplotlib.image import BboxImage
+
+from matplotlib._png import read_png
+import matplotlib.colors
+from matplotlib.cbook import get_sample_data
+
+class RibbonBox(object):
+
+ original_image = read_png(get_sample_data("Minduka_Present_Blue_Pack.png",
+ asfileobj=False))
+ cut_location = 70
+ b_and_h = original_image[:,:,2]
+ color = original_image[:,:,2] - original_image[:,:,0]
+ alpha = original_image[:,:,3]
+ nx = original_image.shape[1]
+
+ def __init__(self, color):
+ rgb = matplotlib.colors.colorConverter.to_rgb(color)
+
+ im = np.empty(self.original_image.shape,
+ self.original_image.dtype)
+
+
+ im[:,:,:3] = self.b_and_h[:,:,np.newaxis]
+ im[:,:,:3] -= self.color[:,:,np.newaxis]*(1.-np.array(rgb))
+ im[:,:,3] = self.alpha
+
+ self.im = im
+
+
+ def get_stretched_image(self, stretch_factor):
+ stretch_factor = max(stretch_factor, 1)
+ ny, nx, nch = self.im.shape
+ ny2 = int(ny*stretch_factor)
+
+ stretched_image = np.empty((ny2, nx, nch),
+ self.im.dtype)
+ cut = self.im[self.cut_location,:,:]
+ stretched_image[:,:,:] = cut
+ stretched_image[:self.cut_location,:,:] = \
+ self.im[:self.cut_location,:,:]
+ stretched_image[-(ny-self.cut_location):,:,:] = \
+ self.im[-(ny-self.cut_location):,:,:]
+
+ self._cached_im = stretched_image
+ return stretched_image
+
+
+
+class RibbonBoxImage(BboxImage):
+ zorder = 1
+
+ def __init__(self, bbox, color,
+ cmap = None,
+ norm = None,
+ interpolation=None,
+ origin=None,
+ filternorm=1,
+ filterrad=4.0,
+ resample = False,
+ **kwargs
+ ):
+
+ BboxImage.__init__(self, bbox,
+ cmap = None,
+ norm = None,
+ interpolation=None,
+ origin=None,
+ filternorm=1,
+ filterrad=4.0,
+ resample = False,
+ **kwargs
+ )
+
+ self._ribbonbox = RibbonBox(color)
+ self._cached_ny = None
+
+
+ def draw(self, renderer, *args, **kwargs):
+
+ bbox = self.get_window_extent(renderer)
+ stretch_factor = bbox.height / bbox.width
+
+ ny = int(stretch_factor*self._ribbonbox.nx)
+ if self._cached_ny != ny:
+ arr = self._ribbonbox.get_stretched_image(stretch_factor)
+ self.set_array(arr)
+ self._cached_ny = ny
+
+ BboxImage.draw(self, renderer, *args, **kwargs)
+
+
+if 1:
+ from matplotlib.transforms import Bbox, TransformedBbox
+ from matplotlib.ticker import ScalarFormatter
+
+ fig = plt.gcf()
+ fig.clf()
+ ax = plt.subplot(111)
+
+ years = np.arange(2004, 2009)
+ box_colors = [(0.8, 0.2, 0.2),
+ (0.2, 0.8, 0.2),
+ (0.2, 0.2, 0.8),
+ (0.7, 0.5, 0.8),
+ (0.3, 0.8, 0.7),
+ ]
+ heights = np.random.random(years.shape) * 7000 + 3000
+
+ fmt = ScalarFormatter(useOffset=False)
+ ax.xaxis.set_major_formatter(fmt)
+
+ for year, h, bc in zip(years, heights, box_colors):
+ bbox0 = Bbox.from_extents(year-0.4, 0., year+0.4, h)
+ bbox = TransformedBbox(bbox0, ax.transData)
+ rb_patch = RibbonBoxImage(bbox, bc)
+
+ ax.add_artist(rb_patch)
+
+ ax.annotate(r"%d" % (int(h/100.)*100),
+ (year, h), va="bottom", ha="center")
+
+ patch_gradient = BboxImage(ax.bbox,
+ interpolation="bicubic",
+ zorder=0.1,
+ )
+ gradient = np.zeros((2, 2, 4), dtype=np.float)
+ gradient[:,:,:3] = [1, 1, 0.]
+ gradient[:,:,3] = [[0.1, 0.3],[0.3, 0.5]] # alpha channel
+ patch_gradient.set_array(gradient)
+ ax.add_artist(patch_gradient)
+
+
+ ax.set_xlim(years[0]-0.5, years[-1]+0.5)
+ ax.set_ylim(0, 10000)
+
+ plt.show()
+
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2009-08-08 01:46:44 UTC (rev 7422)
+++ trunk/matplotlib/lib/matplotlib/image.py 2009-08-08 02:06:56 UTC (rev 7423)
@@ -24,6 +24,8 @@
# the image namespace:
from matplotlib._image import *
+from matplotlib.transforms import BboxBase
+
class AxesImage(martist.Artist, cm.ScalarMappable):
zorder = 1
# map interpolation strings to module constants
@@ -744,6 +746,149 @@
rows, cols, buffer = im.as_rgba_str()
_png.write_png(buffer, cols, rows, fname)
+
+class BboxImage(AxesImage):
+ """
+ The Image class whose size is determined by the given bbox.
+ """
+ zorder = 1
+ def __init__(self, bbox,
+ cmap = None,
+ norm = None,
+ interpolation=None,
+ origin=None,
+ filternorm=1,
+ filterrad=4.0,
+ resample = False,
+ **kwargs
+ ):
+
+ """
+ cmap is a colors.Colormap instance
+ norm is a colors.Normalize instance to map luminance to 0-1
+
+ kwargs are an optional list of Artist keyword args
+ """
+
+ AxesImage.__init__(self, ax=None,
+ cmap = cmap,
+ norm = norm,
+ interpolation=interpolation,
+ origin=origin,
+ filternorm=filternorm,
+ filterrad=filterrad,
+ resample = resample,
+ **kwargs
+ )
+
+ self.bbox = bbox
+
+ def get_window_extent(self, renderer=None):
+ if renderer is None:
+ renderer = self.get_figure()._cachedRenderer
+
+ if isinstance(self.bbox, BboxBase):
+ return self.bbox
+ elif callable(self.bbox):
+ return self.bbox(renderer)
+ else:
+ raise ValueError("unknown type of bbox")
+
+
+ def contains(self, mouseevent):
+ """Test whether the mouse event occured within the image.
+ """
+
+ if callable(self._contains): return self._contains(self,mouseevent)
+
+ if not self.get_visible():# or self.get_figure()._renderer is None:
+ return False,{}
+
+ x, y = mouseevent.x, mouseevent.y
+ inside = self.get_window_extent().contains(x, y)
+
+ return inside,{}
+
+ def get_size(self):
+ 'Get the numrows, numcols of the input image'
+ if self._A is None:
+ raise RuntimeError('You must first set the image array')
+
+ return self._A.shape[:2]
+
+ def make_image(self, renderer, magnification=1.0):
+ if self._A is None:
+ raise RuntimeError('You must first set the image array or the image attribute')
+
+ if self._imcache is None:
+ if self._A.dtype == np.uint8 and len(self._A.shape) == 3:
+ im = _image.frombyte(self._A, 0)
+ im.is_grayscale = False
+ else:
+ if self._rgbacache is None:
+ x = self.to_rgba(self._A, self._alpha)
+ self._rgbacache = x
+ else:
+ x = self._rgbacache
+ im = _image.fromarray(x, 0)
+ if len(self._A.shape) == 2:
+ im.is_grayscale = self.cmap.is_gray()
+ else:
+ im.is_grayscale = False
+ self._imcache = im
+
+ if self.origin=='upper':
+ im.flipud_in()
+ else:
+ im = self._imcache
+
+ if 0:
+ fc = self.axes.patch.get_facecolor()
+ bg = mcolors.colorConverter.to_rgba(fc, 0)
+ im.set_bg( *bg)
+
+ # image input dimensions
+ im.reset_matrix()
+
+ im.set_interpolation(self._interpd[self._interpolation])
+
+ im.set_resample(self._resample)
+
+ l, b, r, t = self.get_window_extent(renderer).extents #bbox.extents
+ widthDisplay = (round(r) + 0.5) - (round(l) - 0.5)
+ heightDisplay = (round(t) + 0.5) - (round(b) - 0.5)
+ widthDisplay *= magnification
+ heightDisplay *= magnification
+ #im.apply_translation(tx, ty)
+
+ numrows, numcols = self._A.shape[:2]
+
+ # resize viewport to display
+ rx = widthDisplay / numcols
+ ry = heightDisplay / numrows
+ #im.apply_scaling(rx*sx, ry*sy)
+ im.apply_scaling(rx, ry)
+ #im.resize(int(widthDisplay+0.5), int(heightDisplay+0.5),
+ # norm=self._filternorm, radius=self._filterrad)
+ im.resize(int(widthDisplay), int(heightDisplay),
+ norm=self._filternorm, radius=self._filterrad)
+ return im
+
+
+ @allow_rasterization
+ def draw(self, renderer, *args, **kwargs):
+ if not self.get_visible(): return
+ # todo: we should be able to do some cacheing here
+ image_mag = renderer.get_image_magnification()
+ im = self.make_image(renderer, image_mag)
+ l, b, r, t = self.get_window_extent(renderer).extents
+ gc = renderer.new_gc()
+ self._set_gc_clip(gc)
+ #gc.set_clip_path(self.get_clip_path())
+ renderer.draw_image(gc, round(l), round(b), im)
+
+
+
def imread(fname):
"""
Return image file in *fname* as :class:`numpy.array`.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-08-08 01:46:56
|
Revision: 7422
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7422&view=rev
Author: efiring
Date: 2009-08-08 01:46:44 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Convert slit paths to compound paths inside cntr.c.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/contour.py
trunk/matplotlib/src/cntr.c
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2009-08-08 01:40:31 UTC (rev 7421)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2009-08-08 01:46:44 UTC (rev 7422)
@@ -539,7 +539,6 @@
"""
self.ax = ax
- self.noslit = kwargs.get('noslit', False) # **Temporary**
self.levels = kwargs.get('levels', None)
self.filled = kwargs.get('filled', False)
self.linewidths = kwargs.get('linewidths', None)
@@ -599,8 +598,6 @@
self.collections = cbook.silent_list('collections.PathCollection')
else:
self.collections = cbook.silent_list('collections.LineCollection')
- self.segs = []
- self.kinds = []
# label lists must be initialized here
self.labelTexts = []
self.labelCValues = []
@@ -629,8 +626,6 @@
alpha=self.alpha)
self.ax.add_collection(col)
self.collections.append(col)
- self.segs.append(segs)
- self.kinds.append(kinds)
else:
tlinewidths = self._process_linewidths()
self.tlinewidths = tlinewidths
@@ -639,7 +634,7 @@
nlist = C.trace(level)
nseg = len(nlist)//2
segs = nlist[:nseg]
- kinds = nlist[nseg:]
+ #kinds = nlist[nseg:]
col = collections.LineCollection(segs,
linewidths = width,
linestyle = lstyle,
@@ -648,24 +643,16 @@
col.set_label('_nolegend_')
self.ax.add_collection(col, False)
self.collections.append(col)
- self.segs.append(segs)
- self.kinds.append(kinds)
self.changed() # set the colors
def _make_paths(self, segs, kinds):
paths = []
for seg, kind in zip(segs, kinds):
- codes = np.zeros(kind.shape, dtype=mpath.Path.code_type)
- codes.fill(mpath.Path.LINETO)
- codes[0] = mpath.Path.MOVETO
- # points that begin a slit or are in it:
- # use moveto for any point *following* such a point
- if self.noslit:
- in_slit = kind[:-1] >= _cntr._slitkind
- codes[1:][in_slit] = mpath.Path.MOVETO
- paths.append(mpath.Path(seg, codes))
+ paths.append(mpath.Path(seg, codes=kind))
return paths
+
+
def changed(self):
tcolors = [ (tuple(rgba),) for rgba in
self.to_rgba(self.cvalues, alpha=self.alpha)]
Modified: trunk/matplotlib/src/cntr.c
===================================================================
--- trunk/matplotlib/src/cntr.c 2009-08-08 01:40:31 UTC (rev 7421)
+++ trunk/matplotlib/src/cntr.c 2009-08-08 01:46:44 UTC (rev 7422)
@@ -1318,9 +1318,134 @@
site = NULL;
}
+#define MOVETO 1
+#define LINETO 2
-/* Build a list of XY 2-D arrays, shape (N,2), to which a list of K arrays
- is concatenated. */
+int reorder(double *xpp, double *ypp, short *kpp,
+ double *xy, unsigned char *c, int npts)
+{
+ int *i0;
+ int *i1;
+ int *subp=NULL; /* initialized to suppress warning */
+ int isp, nsp;
+ int iseg, nsegs;
+ int isegplus;
+ int i;
+ int k;
+ int started;
+ int maxnsegs = npts/2 + 1;
+
+ /* allocate maximum possible size--gross overkill */
+ i0 = malloc(maxnsegs * sizeof(int));
+ i1 = malloc(maxnsegs * sizeof(int));
+
+ /* Find the segments. */
+ iseg = 0;
+ started = 0;
+ for (i=0; i<npts; i++)
+ {
+ if (started)
+ {
+ if ((kpp[i] >= kind_slit_up) || (i == npts-1))
+ {
+ i1[iseg] = i;
+ started = 0;
+ iseg++;
+ if (iseg == maxnsegs)
+ {
+ k = -1;
+ goto ending;
+ }
+ }
+ }
+ else if ((kpp[i] < kind_slit_up) && (i < npts-1))
+ {
+ i0[iseg] = i;
+ started = 1;
+ }
+ }
+
+ nsegs = iseg;
+
+
+ /* Find the subpaths as sets of connected segments. */
+
+ subp = malloc(nsegs * sizeof(int));
+ for (i=0; i<nsegs; i++) subp[i] = -1;
+
+ nsp = 0;
+ for (iseg=0; iseg<nsegs; iseg++)
+ {
+ /* For each segment, if it is not closed, look ahead for
+ the next connected segment.
+ */
+ double xend, yend;
+ xend = xpp[i1[iseg]];
+ yend = ypp[i1[iseg]];
+ if (subp[iseg] >= 0) continue;
+ subp[iseg] = nsp;
+ nsp++;
+ if (iseg == nsegs-1) continue;
+ for (isegplus = iseg+1; isegplus < nsegs; isegplus++)
+ {
+ if (subp[isegplus] >= 0) continue;
+
+ if (xend == xpp[i0[isegplus]] && yend == ypp[i0[isegplus]])
+ {
+ subp[isegplus] = subp[iseg];
+ xend = xpp[i1[isegplus]];
+ yend = ypp[i1[isegplus]];
+ }
+
+ }
+ }
+
+ /* Generate the verts and codes from the subpaths. */
+ k = 0;
+ for (isp=0; isp<nsp; isp++)
+ {
+ int first = 1;
+ for (iseg=0; iseg<nsegs; iseg++)
+ {
+ int istart, iend;
+ if (subp[iseg] != isp) continue;
+ iend = i1[iseg];
+ if (first)
+ {
+ istart = i0[iseg];
+ }
+ else
+ {
+ istart = i0[iseg]+1; /* skip duplicate */
+ }
+ for (i=istart; i<=iend; i++)
+ {
+ xy[2*k] = xpp[i];
+ xy[2*k+1] = ypp[i];
+ if (first) c[k] = MOVETO;
+ else c[k] = LINETO;
+ first = 0;
+ k++;
+ if (k > npts) /* should never happen */
+ {
+ k = -1;
+ goto ending;
+ }
+ }
+ }
+ }
+
+ ending:
+ free(i0);
+ free(i1);
+ free(subp);
+
+ return k;
+}
+
+/* Build a list of XY 2-D arrays, shape (N,2), to which a list of path
+ code arrays is concatenated.
+*/
static PyObject *
build_cntr_list_v2(long *np, double *xp, double *yp, short *kp,
int nparts, long ntotal)
@@ -1331,6 +1456,73 @@
npy_intp dims[2];
npy_intp kdims[1];
int i;
+ long k;
+
+ PyArray_Dims newshape;
+
+ all_contours = PyList_New(nparts*2);
+
+ for (i=0, k=0; i < nparts; k+= np[i], i++)
+ {
+ double *xpp = xp+k;
+ double *ypp = yp+k;
+ short *kpp = kp+k;
+ int n;
+
+
+ dims[0] = np[i];
+ dims[1] = 2;
+ kdims[0] = np[i];
+ xyv = (PyArrayObject *) PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
+ if (xyv == NULL) goto error;
+ kv = (PyArrayObject *) PyArray_SimpleNew(1, kdims, PyArray_UBYTE);
+ if (kv == NULL) goto error;
+
+ n = reorder(xpp, ypp, kpp,
+ (double *) xyv->data,
+ (unsigned char *) kv->data,
+ np[i]);
+ if (n == -1) goto error;
+ newshape.len = 2;
+ dims[0] = n;
+ newshape.ptr = dims;
+ if (PyArray_Resize(xyv, &newshape, 1, NPY_CORDER) == NULL) goto error;
+
+ newshape.len = 1; /* ptr, dims can stay the same */
+ if (PyArray_Resize(kv, &newshape, 1, NPY_CORDER) == NULL) goto error;
+
+
+ if (PyList_SetItem(all_contours, i, (PyObject *)xyv)) goto error;
+ if (PyList_SetItem(all_contours, nparts+i,
+ (PyObject *)kv)) goto error;
+ }
+ return all_contours;
+
+ error:
+ Py_XDECREF(xyv);
+ Py_XDECREF(kv);
+ Py_XDECREF(all_contours);
+ return NULL;
+}
+
+#if 0 /* preprocess this out when we are not using it. */
+/* Build a list of XY 2-D arrays, shape (N,2), to which a list of K arrays
+ is concatenated.
+ This is kept in the code in case we need to switch back to it,
+ or in case we need it for investigating the infamous internal
+ masked region bug.
+*/
+
+static PyObject *
+__build_cntr_list_v2(long *np, double *xp, double *yp, short *kp,
+ int nparts, long ntotal)
+{
+ PyObject *all_contours;
+ PyArrayObject *xyv;
+ PyArrayObject *kv;
+ npy_intp dims[2];
+ npy_intp kdims[1];
+ int i;
long j, k;
all_contours = PyList_New(nparts*2);
@@ -1364,6 +1556,7 @@
return NULL;
}
+#endif /* preprocessing out the old version for now */
/* cntr_trace is called once per contour level or level pair.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-08-08 01:40:37
|
Revision: 7421
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7421&view=rev
Author: leejjoon
Date: 2009-08-08 01:40:31 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
add ribbon box image
Added Paths:
-----------
trunk/sample_data/Minduka_Present_Blue_Pack.png
Added: trunk/sample_data/Minduka_Present_Blue_Pack.png
===================================================================
(Binary files differ)
Property changes on: trunk/sample_data/Minduka_Present_Blue_Pack.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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 (Fri, 07 Aug 2009)
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.
|
|
From: <js...@us...> - 2009-08-07 18:33:10
|
Revision: 7419
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7419&view=rev
Author: jswhit
Date: 2009-08-07 18:33:02 +0000 (Fri, 07 Aug 2009)
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 (Fri, 07 Aug 2009)
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 (Fri, 07 Aug 2009)
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 (Fri, 07 Aug 2009)
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.
|
|
From: <js...@us...> - 2009-08-07 14:26:47
|
Revision: 7415
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7415&view=rev
Author: jswhit
Date: 2009-08-07 14:26:35 +0000 (Fri, 07 Aug 2009)
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 (Fri, 07 Aug 2009)
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 (Fri, 07 Aug 2009)
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.
|