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.
------------------------------------------------------------------------------
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