From: <jd...@us...> - 2010-07-05 23:09:57
|
Revision: 8497 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8497&view=rev Author: jdh2358 Date: 2010-07-05 23:09:51 +0000 (Mon, 05 Jul 2010) Log Message: ----------- support 3d plots in arbitrary axes; thanks Ben Root Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/api/compound_path.py trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Added Paths: ----------- trunk/matplotlib/examples/mplot3d/subplot3d_demo.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2010-07-05 20:47:39 UTC (rev 8496) +++ trunk/matplotlib/CHANGELOG 2010-07-05 23:09:51 UTC (rev 8497) @@ -1,3 +1,8 @@ +2010-07-05 Added Ben Root's patch to put 3D plots in arbitrary axes, + allowing you to mix 3d and 2d in different axes/subplots or + to have multiple 3D plots in one figure. See + examples/mplot3d/subplot3d_demo.py - JDH + 2010-07-05 Preferred kwarg names in set_xlim are now 'left' and 'right'; in set_ylim, 'bottom' and 'top'; original kwargs are still accepted without complaint. - EF Modified: trunk/matplotlib/examples/api/compound_path.py =================================================================== --- trunk/matplotlib/examples/api/compound_path.py 2010-07-05 20:47:39 UTC (rev 8496) +++ trunk/matplotlib/examples/api/compound_path.py 2010-07-05 23:09:51 UTC (rev 8497) @@ -21,7 +21,7 @@ vertices = np.array(vertices, float) path = Path(vertices, codes) -pathpatch = PathPatch(path, facecolor='red', edgecolor='green') +pathpatch = PathPatch(path, facecolor='None', edgecolor='green') fig = plt.figure() ax = fig.add_subplot(111) Added: trunk/matplotlib/examples/mplot3d/subplot3d_demo.py =================================================================== --- trunk/matplotlib/examples/mplot3d/subplot3d_demo.py (rev 0) +++ trunk/matplotlib/examples/mplot3d/subplot3d_demo.py 2010-07-05 23:09:51 UTC (rev 8497) @@ -0,0 +1,30 @@ +from mpl_toolkits.mplot3d.axes3d import Axes3D +from matplotlib import cm +#from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter +import matplotlib.pyplot as plt +import numpy as np + +fig = plt.figure() + +ax = fig.add_subplot(1, 2, 1, projection='3d') +X = np.arange(-5, 5, 0.25) +Y = np.arange(-5, 5, 0.25) +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, cmap=cm.jet, + 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=5) + +from mpl_toolkits.mplot3d.axes3d import get_test_data +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) + +plt.show() + Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2010-07-05 20:47:39 UTC (rev 8496) +++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2010-07-05 23:09:51 UTC (rev 8497) @@ -37,6 +37,7 @@ """ 3D axes object. """ + name = '3d' def __init__(self, fig, rect=None, *args, **kwargs): ''' @@ -1210,3 +1211,11 @@ Z = Z * 500 return X, Y, Z + + +######################################################## +# Register Axes3D as a 'projection' object available +# for use just like any other axes +######################################################## +import matplotlib.projections as proj +proj.projection_registry.register(Axes3D) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |