SF.net SVN: matplotlib:[7426] branches/v0_99_maint/lib/mpl_toolkits/mplot3d
Revision: 7426
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7426&view=rev
Author: jdh2358
Date: 2009-08-08 11:00:41 + (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.
-
+
==
ArgumentDescription
==
@@ -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)) *
SF.net SVN: matplotlib:[7427] trunk/matplotlib
Revision: 7427
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7427&view=rev
Author: jdh2358
Date: 2009-08-08 11:25:32 + (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.
-
+
==
ArgumentDescription
==
@@ -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, h
SF.net SVN: matplotlib:[7428] branches/v0_99_maint/examples/mplot3d
Revision: 7428
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7428&view=rev
Author: jdh2358
Date: 2009-08-08 12:21:29 + (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.py2009-08-08
11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/bars3d_demo.py2009-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.py2009-08-08
11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/contour3d_demo2.py2009-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.py2009-08-08
11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py2009-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.py2009-08-08
11:25:32 UTC (rev 7427)
+++ branches/v0_99_maint/examples/mplot3d/hist3d_demo.py2009
SF.net SVN: matplotlib:[7429] branches/v0_99_maint/examples
Revision: 7429
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7429&view=rev
Author: jdh2358
Date: 2009-08-08 13:53:24 + (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.py2009-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.P
SF.net SVN: matplotlib:[7430] branches/v0_99_maint/examples/animation/ histogram_tkagg.py
Revision: 7430
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7430&view=rev
Author: jdh2358
Date: 2009-08-08 13:58:52 + (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.
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[7431] branches/v0_99_maint
Revision: 7431
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7431&view=rev
Author: jdh2358
Date: 2009-08-08 15:10:08 + (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.py2009-08-08
13:58:52 UTC (rev 7430)
+++ branches/v0_99_maint/examples/api/histogram_path_demo.py2009-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):
"""
SF.net SVN: matplotlib:[7432] branches/v0_99_maint/examples/api/ histogram_path_demo.py
Revision: 7432 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7432&view=rev Author: jdh2358 Date: 2009-08-08 15:16:57 + (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.py2009-08-08 15:10:08 UTC (rev 7431) +++ branches/v0_99_maint/examples/api/histogram_path_demo.py2009-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. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[7433] branches/v0_99_maint/doc/users/annotations. rst
Revision: 7433 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7433&view=rev Author: efiring Date: 2009-08-08 18:16:01 + (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 - === + = widththe width of the arrow in points frac the fraction of the arrow length occupied by the head headwidththe 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. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[7434] trunk/matplotlib
Revision: 7434 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7434&view=rev Author: efiring Date: 2009-08-08 18:24:52 + (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/REA
SF.net SVN: matplotlib:[7435] trunk/matplotlib/examples/pylab_examples/ demo_ribbon_box.py
Revision: 7435 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7435&view=rev Author: leejjoon Date: 2009-08-08 21:11:18 + (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. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[7436] trunk/sample_data
Revision: 7436 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7436&view=rev Author: leejjoon Date: 2009-08-09 04:34:08 + (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. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[7437] trunk/matplotlib
Revision: 7437
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7437&view=rev
Author: leejjoon
Date: 2009-08-09 04:50:12 + (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.py2009-08-09
04:34:08 UTC (rev 7436)
+++ trunk/matplotlib/examples/axes_grid/demo_axes_divider.py2009-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
