|
From: Benjamin R. <ben...@ou...> - 2010-07-24 19:24:18
|
On Sat, Jul 24, 2010 at 7:18 AM, arsbbr <ar...@gm...> wrote: > > Hi, > i'm trying to make a simple 3d plot of a cylinder with plot_surface. > There are two problems in my output: > 1) the shading, shading does not work on the cylindric shell and at the > same > time produces weird > artifacts on the top cover. > http://old.nabble.com/file/p29254649/cyl-shade-error.png > > 2) Sometimes, not reproducible, the inner back of the cylindric shell is > plotted in front of the top cover. It seems, that it depends somehow on the > order of the plot commands, so that switching the two plot command helps... > but not all the time. > http://old.nabble.com/file/p29254649/cyl-clip-error.png > > Am I doing something fundamentally wrong here? > > ########################## > from mpl_toolkits.mplot3d import Axes3D > import matplotlib.pyplot as plt > import numpy as np > from matplotlib import cm > fig = plt.figure() > ax = Axes3D(fig) > > > # Cylindrical shell > phi = np.linspace(0, 2 * np.pi, 100) > r = np.ones(100) > h = np.linspace(0, 1, 100) > > > x = 10 * np.outer(np.cos(phi), r) > y = 10 * np.outer(np.sin(phi), r) > z = 10 * np.outer(np.ones(np.size(r)), h) > > > # Top cover > phi_a = np.linspace(0, 2 * np.pi, 100) > h_2 = np.ones(100) > r_2 = np.linspace(0, 1, 100) > > x_2 = 10 * np.outer(np.cos(phi), r_2) > y_2 = 10 * np.outer(np.sin(phi), r_2) > z_2 = 10 * np.ones([100,100]) > > ax.plot_surface(x, y, z, rstride=9, cstride=15, linewidth=1, alpha=1) > ax.plot_surface(x_2, y_2, z_2, rstride=5, cstride=20, linewidth=1, > alpha=1) > > ax.set_xlabel('X') > ax.set_ylabel('Y') > ax.set_zlabel('Z') > > plt.show() > ########################## > > > I'm just a beginner and installed the Enthought Python Distribution 6.2-2, > which unfortunately > does not use the matplotlib version 1.0. Since I could not find the .egg > install file on the matplotlib site I guess I'll have to wait until they > update EPD.... self compiling is not a real option for me. > > Thanks any suggestions! > > arsbbr, The second problem you mention is a known issue with 3D axes and it is largely due to issues with overlapping objects and trying to determine which one gets displayed on top of the other in a 3D -> 2D environment (oh, how I wish holographic displays were a reality!). You will find that viewing an object from certain angles will cause this issue, and then slightly moving away from those angles will make everything right again. Unfortunately, I do not anticipate this issue being solved anytime soon, although it probably should become a higher priority to me. I think I have seen the first issue before, but I never fully explored it. I think I just found my mini-project for the weekend! I will let you know what I find. Ben Root |