## Re: [Matplotlib-users] Axes3D depth problem

 Re: [Matplotlib-users] Axes3D depth problem From: Benjamin Root - 2010-07-27 21:29:35 Attachments: Message as HTML ```On Tue, Jul 27, 2010 at 3:10 PM, wrote: > Hallo Ben Root, > > I put together some snippets > > #----CODE---- > import matplotlib.pyplot as plt > from matplotlib.patches import Circle > import mpl_toolkits.mplot3d.art3d as art3d > from mpl_toolkits.mplot3d import Axes3D > import numpy > import matplotlib > > step = 0.04 > maxval = 1.0 > > fig = plt.figure() > ax = Axes3D(fig,aspect='equal') > > ri = 0.625 > rj = 1.25 > l = 5 > > ##CONE > r = numpy.linspace(rj,rj,6) > r[0]= numpy.zeros(r[0].shape) > r[1] *= ri/rj > r[5] *= ri/rj > r[3]= numpy.zeros(r[3].shape) > > p = numpy.linspace(0,2*numpy.pi,50) > R,P = numpy.meshgrid(r,p) > > X,Y = R*numpy.cos(P),R*numpy.sin(P) > > tmp=list() > for i in range(50): > tmp.append([0,0,l,l,l,0]) > Z = numpy.array(tmp) > ax.plot_surface(X, Z,Y, rstride=1, cstride=1, color="b") > > ##CIRCLES > p=Circle((0,0),rj,color="red") > ax.add_patch(p) > art3d.patch_2d_to_3d(p, z=l, zdir="y") > > p=Circle((0,0),ri,color="red") > ax.add_patch(p) > art3d.patch_2d_to_3d(p, z=0, zdir="y") > > ax.set_ylim3d(-0.5, l+.5) > ax.set_xlim3d(-l*0.5-0.5, l*0.5+0.5) > ax.set_zlim3d(-l*0.5-0.5, l*0.5+0.5) > > plt.show() > #----CODE---- > > greetz > > Frank > Am 27.07.2010 21:36, schrieb Benjamin Root: > > On Tue, Jul 27, 2010 at 2:25 PM, > > wrote: > > > > Hallo, > > > > I got a depth problem with Axes3D. I made a plot_surface and add 2 > > Circle object with add_patch and > > mpl_toolkits.mplot3d.art3d.patch_2d_to_3d. > > > > The problem is that the circles are always in front. I upload a > > picture here http://yfrog.com/nd3dproblemp . The gui is rotatable, > > so I can't just remove the second Circle (like I did for the > > screenshot). > > > > How to get right order to the object? > > > > greetz > > > > Frank > > > Thanks, At first glance, I am wondering if the problem is that the Circle objects are not properly getting a zsort value when converted to a 3d object. I will see if there is an inconsistency in behavior between different types of patches. Ben Root ```

 [Matplotlib-users] Axes3D depth problem From: - 2010-07-27 19:25:40 ```Hallo, I got a depth problem with Axes3D. I made a plot_surface and add 2 Circle object with add_patch and mpl_toolkits.mplot3d.art3d.patch_2d_to_3d. The problem is that the circles are always in front. I upload a picture here http://yfrog.com/nd3dproblemp . The gui is rotatable, so I can't just remove the second Circle (like I did for the screenshot). How to get right order to the object? greetz Frank ```
 Re: [Matplotlib-users] Axes3D depth problem From: Benjamin Root - 2010-07-27 19:37:21 Attachments: Message as HTML ```On Tue, Jul 27, 2010 at 2:25 PM, wrote: > Hallo, > > I got a depth problem with Axes3D. I made a plot_surface and add 2 Circle > object with add_patch and mpl_toolkits.mplot3d.art3d.patch_2d_to_3d. > > The problem is that the circles are always in front. I upload a picture > here http://yfrog.com/nd3dproblemp . The gui is rotatable, so I can't just > remove the second Circle (like I did for the screenshot). > > How to get right order to the object? > > greetz > > Frank > > Frank, Could you please include a script that reproduces this? There have been some issues like this reported before, but it would only occur at certain viewing angles. Is this problem occurring regardless of what viewing angle you are looking at the plot? It would be useful to have an example that *always* looks bad for fixing purposes. Ben Root ```
 Re: [Matplotlib-users] Axes3D depth problem From: - 2010-07-27 20:10:27 ```Hallo Ben Root, I put together some snippets #----CODE---- import matplotlib.pyplot as plt from matplotlib.patches import Circle import mpl_toolkits.mplot3d.art3d as art3d from mpl_toolkits.mplot3d import Axes3D import numpy import matplotlib step = 0.04 maxval = 1.0 fig = plt.figure() ax = Axes3D(fig,aspect='equal') ri = 0.625 rj = 1.25 l = 5 ##CONE r = numpy.linspace(rj,rj,6) r[0]= numpy.zeros(r[0].shape) r[1] *= ri/rj r[5] *= ri/rj r[3]= numpy.zeros(r[3].shape) p = numpy.linspace(0,2*numpy.pi,50) R,P = numpy.meshgrid(r,p) X,Y = R*numpy.cos(P),R*numpy.sin(P) tmp=list() for i in range(50): tmp.append([0,0,l,l,l,0]) Z = numpy.array(tmp) ax.plot_surface(X, Z,Y, rstride=1, cstride=1, color="b") ##CIRCLES p=Circle((0,0),rj,color="red") ax.add_patch(p) art3d.patch_2d_to_3d(p, z=l, zdir="y") p=Circle((0,0),ri,color="red") ax.add_patch(p) art3d.patch_2d_to_3d(p, z=0, zdir="y") ax.set_ylim3d(-0.5, l+.5) ax.set_xlim3d(-l*0.5-0.5, l*0.5+0.5) ax.set_zlim3d(-l*0.5-0.5, l*0.5+0.5) plt.show() #----CODE---- greetz Frank Am 27.07.2010 21:36, schrieb Benjamin Root: > On Tue, Jul 27, 2010 at 2:25 PM, > wrote: > > Hallo, > > I got a depth problem with Axes3D. I made a plot_surface and add 2 > Circle object with add_patch and > mpl_toolkits.mplot3d.art3d.patch_2d_to_3d. > > The problem is that the circles are always in front. I upload a > picture here http://yfrog.com/nd3dproblemp . The gui is rotatable, > so I can't just remove the second Circle (like I did for the > screenshot). > > How to get right order to the object? > > greetz > > Frank > > > Frank, > > Could you please include a script that reproduces this? There have been > some issues like this reported before, but it would only occur at > certain viewing angles. Is this problem occurring regardless of what > viewing angle you are looking at the plot? It would be useful to have > an example that *always* looks bad for fixing purposes. > > Ben Root ```
 Re: [Matplotlib-users] Axes3D depth problem From: Benjamin Root - 2010-07-27 21:29:35 Attachments: Message as HTML ```On Tue, Jul 27, 2010 at 3:10 PM, wrote: > Hallo Ben Root, > > I put together some snippets > > #----CODE---- > import matplotlib.pyplot as plt > from matplotlib.patches import Circle > import mpl_toolkits.mplot3d.art3d as art3d > from mpl_toolkits.mplot3d import Axes3D > import numpy > import matplotlib > > step = 0.04 > maxval = 1.0 > > fig = plt.figure() > ax = Axes3D(fig,aspect='equal') > > ri = 0.625 > rj = 1.25 > l = 5 > > ##CONE > r = numpy.linspace(rj,rj,6) > r[0]= numpy.zeros(r[0].shape) > r[1] *= ri/rj > r[5] *= ri/rj > r[3]= numpy.zeros(r[3].shape) > > p = numpy.linspace(0,2*numpy.pi,50) > R,P = numpy.meshgrid(r,p) > > X,Y = R*numpy.cos(P),R*numpy.sin(P) > > tmp=list() > for i in range(50): > tmp.append([0,0,l,l,l,0]) > Z = numpy.array(tmp) > ax.plot_surface(X, Z,Y, rstride=1, cstride=1, color="b") > > ##CIRCLES > p=Circle((0,0),rj,color="red") > ax.add_patch(p) > art3d.patch_2d_to_3d(p, z=l, zdir="y") > > p=Circle((0,0),ri,color="red") > ax.add_patch(p) > art3d.patch_2d_to_3d(p, z=0, zdir="y") > > ax.set_ylim3d(-0.5, l+.5) > ax.set_xlim3d(-l*0.5-0.5, l*0.5+0.5) > ax.set_zlim3d(-l*0.5-0.5, l*0.5+0.5) > > plt.show() > #----CODE---- > > greetz > > Frank > Am 27.07.2010 21:36, schrieb Benjamin Root: > > On Tue, Jul 27, 2010 at 2:25 PM, > > wrote: > > > > Hallo, > > > > I got a depth problem with Axes3D. I made a plot_surface and add 2 > > Circle object with add_patch and > > mpl_toolkits.mplot3d.art3d.patch_2d_to_3d. > > > > The problem is that the circles are always in front. I upload a > > picture here http://yfrog.com/nd3dproblemp . The gui is rotatable, > > so I can't just remove the second Circle (like I did for the > > screenshot). > > > > How to get right order to the object? > > > > greetz > > > > Frank > > > Thanks, At first glance, I am wondering if the problem is that the Circle objects are not properly getting a zsort value when converted to a 3d object. I will see if there is an inconsistency in behavior between different types of patches. Ben Root ```