Revision: 8543
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8543&view=rev
Author:   weathergod
Date:     2010-07-14 02:42:19 +0000 (Wed, 14 Jul 2010)

Log Message:
-----------
Added documentation and examples for new, easier Axes3D use.

Modified Paths:
--------------
    branches/v1_0_maint/doc/mpl_toolkits/mplot3d/tutorial.rst
    branches/v1_0_maint/examples/mplot3d/2dcollections3d_demo.py
    branches/v1_0_maint/examples/mplot3d/bars3d_demo.py
    branches/v1_0_maint/examples/mplot3d/contour3d_demo.py
    branches/v1_0_maint/examples/mplot3d/contour3d_demo2.py
    branches/v1_0_maint/examples/mplot3d/contour3d_demo3.py
    branches/v1_0_maint/examples/mplot3d/contourf3d_demo.py
    branches/v1_0_maint/examples/mplot3d/hist3d_demo.py
    branches/v1_0_maint/examples/mplot3d/lines3d_demo.py
    branches/v1_0_maint/examples/mplot3d/pathpatch3d_demo.py
    branches/v1_0_maint/examples/mplot3d/polys3d_demo.py
    branches/v1_0_maint/examples/mplot3d/rotate_axes3d_demo.py
    branches/v1_0_maint/examples/mplot3d/scatter3d_demo.py
    branches/v1_0_maint/examples/mplot3d/subplot3d_demo.py
    branches/v1_0_maint/examples/mplot3d/surface3d_demo.py
    branches/v1_0_maint/examples/mplot3d/surface3d_demo2.py
    branches/v1_0_maint/examples/mplot3d/surface3d_demo3.py
    branches/v1_0_maint/examples/mplot3d/surface3d_radial_demo.py
    branches/v1_0_maint/examples/mplot3d/text3d_demo.py
    branches/v1_0_maint/examples/mplot3d/wire3d_animation_demo.py
    branches/v1_0_maint/examples/mplot3d/wire3d_demo.py

Added Paths:
-----------
    branches/v1_0_maint/examples/mplot3d/mixed_subplots_demo.py

Modified: branches/v1_0_maint/doc/mpl_toolkits/mplot3d/tutorial.rst
===================================================================
--- branches/v1_0_maint/doc/mpl_toolkits/mplot3d/tutorial.rst   2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/doc/mpl_toolkits/mplot3d/tutorial.rst   2010-07-14 
02:42:19 UTC (rev 8543)
@@ -7,13 +7,15 @@
 
 Getting started
 ===============
-Create a new :class:`matplotlib.figure.Figure` and an
-:class:`~mpl_toolkits.mplot3d.Axes3D` object in it::
+An Axes3D object is created just like any other axes using
+the projection='3d' keyword.
+Create a new :class:`matplotlib.figure.Figure` and
+add a new axes to it of type :class:`~mpl_toolkits.mplot3d.Axes3D`::
 
-  import pylab
-  fig = pylab.figure()
+  import matplotlib.pyplot as plt
   from mpl_toolkits.mplot3d import Axes3D
-  ax = Axes3D(fig)
+  fig = pyplt.figure()
+  ax = fig.add_subplot(111, projection='3d')
 
 Line plots
 ====================
@@ -39,6 +41,7 @@
 
 .. plot:: mpl_examples/mplot3d/surface3d_demo.py
 .. plot:: mpl_examples/mplot3d/surface3d_demo2.py
+.. plot:: mpl_examples/mplot3d/surface3d_demo3.py
 
 Contour plots
 =============
@@ -46,6 +49,7 @@
 
 .. plot:: mpl_examples/mplot3d/contour3d_demo.py
 .. plot:: mpl_examples/mplot3d/contour3d_demo2.py
+.. plot:: mpl_examples/mplot3d/contour3d_demo3.py
 
 Filled contour plots
 ====================
@@ -75,3 +79,11 @@
 
 .. plot:: mpl_examples/mplot3d/text3d_demo.py
 
+Subplotting
+====================
+Having multiple 3D plots in a single figure is the same
+as it is for 2D plots. And you can mix 2D and 3D plots
+into the same figure.
+
+.. plot:: mpl_examples/mplot3d/subplot3d_demo.py
+.. plot:: mpl_examples/mplot3d/mixed_subplots_demo.py

Modified: branches/v1_0_maint/examples/mplot3d/2dcollections3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/2dcollections3d_demo.py        
2010-07-13 16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/2dcollections3d_demo.py        
2010-07-14 02:42:19 UTC (rev 8543)
@@ -3,7 +3,7 @@
 import matplotlib.pyplot as plt
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.gca(projection='3d')
 
 x = np.linspace(0, 1, 100)
 y = np.sin(x * 2 * np.pi) / 2 + 0.5

Modified: branches/v1_0_maint/examples/mplot3d/bars3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/bars3d_demo.py 2010-07-13 16:48:20 UTC 
(rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/bars3d_demo.py 2010-07-14 02:42:19 UTC 
(rev 8543)
@@ -3,7 +3,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
     xs = np.arange(20)
     ys = np.random.rand(20)

Modified: branches/v1_0_maint/examples/mplot3d/contour3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/contour3d_demo.py      2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/contour3d_demo.py      2010-07-14 
02:42:19 UTC (rev 8543)
@@ -2,7 +2,7 @@
 import matplotlib.pyplot as plt
 
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 X, Y, Z = axes3d.get_test_data(0.05)
 cset = ax.contour(X, Y, Z)
 ax.clabel(cset, fontsize=9, inline=1)

Modified: branches/v1_0_maint/examples/mplot3d/contour3d_demo2.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/contour3d_demo2.py     2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/contour3d_demo2.py     2010-07-14 
02:42:19 UTC (rev 8543)
@@ -2,7 +2,7 @@
 import matplotlib.pyplot as plt
 
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.gca(projection='3d')
 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)

Modified: branches/v1_0_maint/examples/mplot3d/contour3d_demo3.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/contour3d_demo3.py     2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/contour3d_demo3.py     2010-07-14 
02:42:19 UTC (rev 8543)
@@ -2,7 +2,7 @@
 import matplotlib.pyplot as plt
 
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.gca(projection='3d')
 X, Y, Z = axes3d.get_test_data(0.05)
 ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
 cset = ax.contour(X, Y, Z, zdir='z', offset=-100)

Modified: branches/v1_0_maint/examples/mplot3d/contourf3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/contourf3d_demo.py     2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/contourf3d_demo.py     2010-07-14 
02:42:19 UTC (rev 8543)
@@ -2,7 +2,7 @@
 import matplotlib.pyplot as plt
 
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.gca(projection='3d')
 X, Y, Z = axes3d.get_test_data(0.05)
 cset = ax.contourf(X, Y, Z)
 ax.clabel(cset, fontsize=9, inline=1)

Modified: branches/v1_0_maint/examples/mplot3d/hist3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/hist3d_demo.py 2010-07-13 16:48:20 UTC 
(rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/hist3d_demo.py 2010-07-14 02:42:19 UTC 
(rev 8543)
@@ -3,7 +3,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 x, y = np.random.rand(2, 100) * 4
 hist, xedges, yedges = np.histogram2d(x, y, bins=4)
 

Modified: branches/v1_0_maint/examples/mplot3d/lines3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/lines3d_demo.py        2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/lines3d_demo.py        2010-07-14 
02:42:19 UTC (rev 8543)
@@ -6,7 +6,7 @@
 mpl.rcParams['legend.fontsize'] = 10
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.gca(projection='3d')
 theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
 z = np.linspace(-2, 2, 100)
 r = z**2 + 1

Added: branches/v1_0_maint/examples/mplot3d/mixed_subplots_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/mixed_subplots_demo.py                 
        (rev 0)
+++ branches/v1_0_maint/examples/mplot3d/mixed_subplots_demo.py 2010-07-14 
02:42:19 UTC (rev 8543)
@@ -0,0 +1,48 @@
+"""
+Demonstrate the mixing of 2d and 3d subplots
+"""
+from mpl_toolkits.mplot3d import Axes3D
+import matplotlib.pyplot as plt
+import numpy as np
+
+def f(t):
+    s1 = np.cos(2*np.pi*t)
+    e1 = np.exp(-t)
+    return np.multiply(s1,e1)
+
+
+################
+# First subplot
+################
+t1 = np.arange(0.0, 5.0, 0.1)
+t2 = np.arange(0.0, 5.0, 0.02)
+t3 = np.arange(0.0, 2.0, 0.01)
+
+fig = plt.figure()
+fig.suptitle('A tale of 2 subplots')
+ax = fig.add_subplot(2, 1, 1)
+l = ax.plot(t1, f(t1), 'bo', 
+            t2, f(t2), 'k--', markerfacecolor='green')
+ax.grid(True)
+ax.set_ylabel('Damped oscillation')
+
+
+#################
+# Second subplot
+#################
+ax = fig.add_subplot(2, 1, 2, projection='3d')
+X = np.arange(-5, 5, 0.25)
+xlen = len(X)
+Y = np.arange(-5, 5, 0.25)
+ylen = len(Y)
+X, Y = np.meshgrid(X, Y)
+R = np.sqrt(X**2 + Y**2)
+Z = np.sin(R)
+
+surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
+        linewidth=0, antialiased=False)
+
+ax.set_zlim3d(-1, 1)
+
+plt.show()
+

Modified: branches/v1_0_maint/examples/mplot3d/pathpatch3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/pathpatch3d_demo.py    2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/pathpatch3d_demo.py    2010-07-14 
02:42:19 UTC (rev 8543)
@@ -25,7 +25,7 @@
 
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 
 p = Circle((5, 5), 3)
 ax.add_patch(p)

Modified: branches/v1_0_maint/examples/mplot3d/polys3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/polys3d_demo.py        2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/polys3d_demo.py        2010-07-14 
02:42:19 UTC (rev 8543)
@@ -5,7 +5,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.gca(projection='3d')
 
 cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
 

Modified: branches/v1_0_maint/examples/mplot3d/rotate_axes3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/rotate_axes3d_demo.py  2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/rotate_axes3d_demo.py  2010-07-14 
02:42:19 UTC (rev 8543)
@@ -5,7 +5,7 @@
 plt.ion()
 
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 X, Y, Z = axes3d.get_test_data(0.1)
 ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
 

Modified: branches/v1_0_maint/examples/mplot3d/scatter3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/scatter3d_demo.py      2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/scatter3d_demo.py      2010-07-14 
02:42:19 UTC (rev 8543)
@@ -6,7 +6,7 @@
     return (vmax-vmin)*np.random.rand(n) + vmin
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 n = 100
 for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
     xs = randrange(n, 23, 32)

Modified: branches/v1_0_maint/examples/mplot3d/subplot3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/subplot3d_demo.py      2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/subplot3d_demo.py      2010-07-14 
02:42:19 UTC (rev 8543)
@@ -1,11 +1,16 @@
 from mpl_toolkits.mplot3d.axes3d import Axes3D
-from matplotlib import cm
-#from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter
 import matplotlib.pyplot as plt
+
+
+# imports specific to the plots in this example
 import numpy as np
+from matplotlib import cm
+from mpl_toolkits.mplot3d.axes3d import get_test_data
 
-fig = plt.figure()
 
+fig = plt.figure(figsize=(9.5,5.0))
+
+#---- First subplot
 ax = fig.add_subplot(1, 2, 1, projection='3d')
 X = np.arange(-5, 5, 0.25)
 Y = np.arange(-5, 5, 0.25)
@@ -16,12 +21,9 @@
         linewidth=0, antialiased=False)
 ax.set_zlim3d(-1.01, 1.01)
 
-#ax.w_zaxis.set_major_locator(LinearLocator(10))
-#ax.w_zaxis.set_major_formatter(FormatStrFormatter('%.03f'))
+fig.colorbar(surf, shrink=0.5, aspect=10)
 
-fig.colorbar(surf, shrink=0.5, aspect=5)
-
-from mpl_toolkits.mplot3d.axes3d import get_test_data
+#---- Second subplot
 ax = fig.add_subplot(1, 2, 2, projection='3d')
 X, Y, Z = get_test_data(0.05)
 ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

Modified: branches/v1_0_maint/examples/mplot3d/surface3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/surface3d_demo.py      2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/surface3d_demo.py      2010-07-14 
02:42:19 UTC (rev 8543)
@@ -5,7 +5,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.gca(projection='3d')
 X = np.arange(-5, 5, 0.25)
 Y = np.arange(-5, 5, 0.25)
 X, Y = np.meshgrid(X, Y)

Modified: branches/v1_0_maint/examples/mplot3d/surface3d_demo2.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/surface3d_demo2.py     2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/surface3d_demo2.py     2010-07-14 
02:42:19 UTC (rev 8543)
@@ -3,7 +3,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 
 u = np.linspace(0, 2 * np.pi, 100)
 v = np.linspace(0, np.pi, 100)

Modified: branches/v1_0_maint/examples/mplot3d/surface3d_demo3.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/surface3d_demo3.py     2010-07-13 
16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/surface3d_demo3.py     2010-07-14 
02:42:19 UTC (rev 8543)
@@ -5,7 +5,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.gca(projection='3d')
 X = np.arange(-5, 5, 0.25)
 xlen = len(X)
 Y = np.arange(-5, 5, 0.25)

Modified: branches/v1_0_maint/examples/mplot3d/surface3d_radial_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/surface3d_radial_demo.py       
2010-07-13 16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/surface3d_radial_demo.py       
2010-07-14 02:42:19 UTC (rev 8543)
@@ -8,7 +8,7 @@
 step = 0.04
 maxval = 1.0
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 
 # create supporting points in polar coordinates
 r = np.linspace(0,1.25,50)

Modified: branches/v1_0_maint/examples/mplot3d/text3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/text3d_demo.py 2010-07-13 16:48:20 UTC 
(rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/text3d_demo.py 2010-07-14 02:42:19 UTC 
(rev 8543)
@@ -2,7 +2,7 @@
 import matplotlib.pyplot as plt
 
 fig = plt.figure()
-ax = Axes3D(fig)
+ax = fig.gca(projection='3d')
 
 zdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1))
 xs = (2, 6, 4, 9, 7, 2)

Modified: branches/v1_0_maint/examples/mplot3d/wire3d_animation_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/wire3d_animation_demo.py       
2010-07-13 16:48:20 UTC (rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/wire3d_animation_demo.py       
2010-07-14 02:42:19 UTC (rev 8543)
@@ -1,3 +1,6 @@
+"""
+A very simple 'animation' of a 3D plot
+"""
 from mpl_toolkits.mplot3d import axes3d
 import matplotlib.pyplot as plt
 import numpy as np
@@ -9,7 +12,7 @@
 
 plt.ion()
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 
 xs = np.linspace(-1, 1, 50)
 ys = np.linspace(-1, 1, 50)

Modified: branches/v1_0_maint/examples/mplot3d/wire3d_demo.py
===================================================================
--- branches/v1_0_maint/examples/mplot3d/wire3d_demo.py 2010-07-13 16:48:20 UTC 
(rev 8542)
+++ branches/v1_0_maint/examples/mplot3d/wire3d_demo.py 2010-07-14 02:42:19 UTC 
(rev 8543)
@@ -3,7 +3,7 @@
 import numpy as np
 
 fig = plt.figure()
-ax = axes3d.Axes3D(fig)
+ax = fig.add_subplot(111, projection='3d')
 X, Y, Z = axes3d.get_test_data(0.05)
 ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to