Since I haven't found an example, that shows howto plot in 3d a cube and pyramid, respectively, I wanted to show how I accomplished this without using vtk or mayavi. Unfortunately, it is a bit of an ugly hack, since as far as i know the plotsurface method cannot directly plot arrays with shape (,x).
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np
fig=plt.figure() ax = Axes3D(fig) # Face 1 x1 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) y1 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) z1 = np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) # Face 2 x2 = np.array([[0, 0, 0.5, 0], [0, 0, 0, 0]]) y2 = np.array([[0, 1, 0.5, 0], [0, 0, 0, 0]]) z2 = np.array([[0, 0, 1, 0], [0, 0, 0, 0]]) # Face 3 x3 = np.array([[1, 1, 0.5, 1], [1, 1, 1, 1]]) y3 = np.array([[0, 1, 0.5, 0], [0, 0, 0, 0]]) z3 = np.array([[0, 0, 1, 0], [0, 0, 0, 0]]) # Face 4 x4 = np.array([[0, 1, 0.5, 0], [0, 0, 0, 0]]) y4 = np.array([[1, 1, 0.5, 1], [1, 1, 1, 1]]) z4 = np.array([[0, 0, 1, 0], [0, 0, 0, 0]]) # Face 5 x5 = np.array([[1, 0, 0.5, 1], [1, 1, 1, 1]]) y5 = np.array([[0, 0, 0.5, 0], [0, 0, 0, 0]]) z5 = np.array([[0, 0, 1, 0], [0, 0, 0, 0]]) ax.plot_surface(x1,y1,z1) ax.plot_surface(x2,y2,z2) ax.plot_surface(x3,y3,z3) ax.plot_surface(x4,y4,z4) ax.plot_surface(x5,y5,z5) plt.show()
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig=plt.figure() ax = Axes3D(fig) # Face 1 x1 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) y1 = np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) z1 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) # Face 2 x2 = np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) y2 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) z2 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) # Face 3 x3 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) y3 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) z3 = np.array([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) # Face 4 x4 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) y4 = np.array([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) z4 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) # Face 5 x5 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) y5 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) z5 = np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) # Face 6 x6 = np.array([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) y6 = np.array([[0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) z6 = np.array([[0, 0, 1, 1, 0], [0, 0, 0, 0, 0]]) ax.plot_surface(x1,y1,z1) ax.plot_surface(x2,y2,z2) ax.plot_surface(x3,y3,z3) ax.plot_surface(x4,y4,z4) ax.plot_surface(x5,y5,z5) ax.plot_surface(x6,y6,z6) plt.show()
------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users