Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e993529

Browse files
committed
mplot3d: update axes code, add support for '3D' text.
Split and add examples and begin documentation. svn path=/trunk/matplotlib/; revision=7198
1 parent 56314cd commit e993529

17 files changed

Lines changed: 741 additions & 793 deletions

doc/devel/documenting_mpl.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Getting started
99

1010
The documentation for matplotlib is generated from ReStructured Text
1111
using the Sphinx_ documentation generation tool. Sphinx-0.5 or later
12-
is required. Most developers work from the sphinx subversion repository because it is a rapidly evolving project::
12+
is required. You might still run into problems, so most developers
13+
work from the sphinx source repository (Mercurial based) because it
14+
is a rapidly evolving project::
1315

14-
svn co http://svn.python.org/projects/doctools/trunk sphinx
16+
hg clone http://bitbucket.org/birkenfeld/sphinx/
1517
cd sphinx
1618
python setup.py install
1719

doc/users/toolkits.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ line, mesh) tools. Not the fastest or feature complete 3D library out
5454
there, but ships with matplotlib and thus may be a lighter weight
5555
solution for some use cases.
5656

57+
See :ref:`toolkit_mplot3d-index` for more documentation and examples.
5758

5859
.. _toolkit_axes_grid:
5960

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from mpl_toolkits.mplot3d import Axes3D
2+
import numpy as np
3+
import pylab
4+
5+
fig = pylab.figure()
6+
ax = Axes3D(fig)
7+
8+
x = np.linspace(0, 1, 100)
9+
y = np.sin(x * 2 * np.pi) / 2 + 0.5
10+
ax.plot(x, y, zs=0, zdir='z', label='zs=0, zdir=z')
11+
12+
colors = ('r', 'g', 'b', 'k')
13+
for c in colors:
14+
x = np.random.sample(20)
15+
y = np.random.sample(20)
16+
ax.scatter(x, y, 0, zdir='y', c=c)
17+
18+
ax.legend()
19+
ax.set_xlim3d(0, 1)
20+
ax.set_ylim3d(0, 1)
21+
ax.set_zlim3d(0, 1)
22+
23+
pylab.show()
24+

examples/mplot3d/bars3d_demo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from mpl_toolkits.mplot3d import Axes3D
2+
from matplotlib.collections import PolyCollection
3+
from matplotlib.colors import colorConverter
4+
import pylab
5+
import random
6+
import numpy as np
7+
8+
fig = pylab.figure()
9+
ax = Axes3D(fig)
10+
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
11+
xs = np.arange(20)
12+
ys = [random.random() for x in xs]
13+
ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)
14+
15+
ax.set_xlabel('X')
16+
ax.set_ylabel('Y')
17+
ax.set_zlabel('Z')
18+
19+
pylab.show()
20+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fig = pylab.figure()
66
ax = axes3d.Axes3D(fig)
77
X, Y, Z = axes3d.get_test_data(0.05)
8-
cset = ax.contour3D(X, Y, Z)
8+
cset = ax.contour(X, Y, Z)
99
ax.clabel(cset, fontsize=9, inline=1)
1010

1111
pylab.show()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fig = pylab.figure()
66
ax = axes3d.Axes3D(fig)
77
X, Y, Z = axes3d.get_test_data(0.05)
8-
cset = ax.contourf3D(X, Y, Z)
8+
cset = ax.contourf(X, Y, Z)
99
ax.clabel(cset, fontsize=9, inline=1)
1010

1111
pylab.show()

examples/mplot3d/demo.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

examples/mplot3d/lines3d_demo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import matplotlib as mpl
2+
from mpl_toolkits.mplot3d import Axes3D
3+
import numpy as np
4+
import pylab
5+
6+
mpl.rcParams['legend.fontsize'] = 10
7+
8+
fig = pylab.figure()
9+
ax = Axes3D(fig)
10+
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
11+
z = np.linspace(-2, 2, 100)
12+
r = z**2 + 1
13+
x = r * np.sin(theta)
14+
y = r * np.cos(theta)
15+
ax.plot(x, y, z, label='parametric curve')
16+
ax.legend()
17+
18+
pylab.show()
19+
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
poly = PolyCollection(verts, facecolors = [cc('r'), cc('g'), cc('b'),
2222
cc('y')])
2323
poly.set_alpha(0.7)
24-
ax.add_collection(poly, zs=zs, dir='y')
24+
ax.add_collection3d(poly, zs=zs, zdir='y')
2525

26-
ax.set_xlim(0, 10)
27-
ax.set_ylim(-1, 4)
28-
ax.set_zlim(0, 1)
26+
ax.set_xlim3d(0, 10)
27+
ax.set_ylim3d(-1, 4)
28+
ax.set_zlim3d(0, 1)
2929

3030
pylab.show()
3131

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
random.randrange(100),
1212
random.randrange(zl, zh)
1313
) for i in range(n)])
14-
ax.scatter3D(xs, ys, zs, c=c)
14+
ax.scatter(xs, ys, zs, c=c)
1515

1616
ax.set_xlabel('X Label')
1717
ax.set_ylabel('Y Label')

0 commit comments

Comments
 (0)