 # Axes3D depth problem

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

···

On Tue, Jul 27, 2010 at 2:25 PM, <copyrights@…380…> 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

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= numpy.zeros(r.shape)
r *= ri/rj
r *= ri/rj
r= numpy.zeros(r.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")
art3d.patch_2d_to_3d(p, z=l, zdir="y")

p=Circle((0,0),ri,color="red")
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, <copyrights@…380… > <mailto:copyrights@…380…>> wrote:

Hallo,

I got a depth problem with Axes3D. I made a plot_surface and add 2
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

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

···

On Tue, Jul 27, 2010 at 3:10 PM, <copyrights@…380…> 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= numpy.zeros(r.shape)

r *= ri/rj

r *= ri/rj

r= numpy.zeros(r.shape)

p = numpy.linspace(0,2*numpy.pi,50)

R,P = numpy.meshgrid(r,p)

X,Y = Rnumpy.cos§,Rnumpy.sin§

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”)

art3d.patch_2d_to_3d(p, z=l, zdir=“y”)

p=Circle((0,0),ri,color=“red”)

art3d.patch_2d_to_3d(p, z=0, zdir=“y”)

ax.set_ylim3d(-0.5, l+.5)

ax.set_xlim3d(-l0.5-0.5, l0.5+0.5)

ax.set_zlim3d(-l0.5-0.5, l0.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, <copyrights@…380… > > mailto:copyrights@...380...> 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](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
``````