3d contourf and ax.set

Hello,

I have some minor questions regarding matplotlib. I'm using it to make a 3d
plot, displaying a surface, it's contour map, a line climbing the surface
and its projection onto the contour map.

http://old.nabble.com/file/p34015720/landscape_draft.png landscape_draft.png

As you can see, when the lines cross the contourf, they are somewhat
obscured. Before I made the contourf transparent, the lines were blocked,
even though they were above the contour plot when I viewed the picture from
a different angle. Can this be fixed? I want the lines to appear on top of
the contour plot.

Also, I am trying to extend the z axis to be lower. This is most of the code
I'm using:

fig=plt.figure(1)
ax=fig.gca(projection='3d')

x=np.arange(0,2.5,.02)
y=np.arange(0,2.3,.02)
x,y=np.meshgrid(x,y)

ax.plot_surface(x,y,Z(x,y),alpha=0.3)

cset=ax.contourf(x,y,Z(x,y),zdir='z',offset=-2,
cmap=plt.cm.jet,levels=np.linspace(0,9,100),alpha=0.5)

ax.set_xlabel('x')
ax.set_ylabel('y')

ax.set_zlim(-2,8) #This is where I try to change the z axis limits.

plt.show()

I'm excluding the code which plots the lines. ax.set_zlim doesn't do
anything; why is this?

···

--
View this message in context: http://old.nabble.com/3d-contourf-and-ax.set-tp34015720p34015720.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Ananduri,

Hello,

I have some minor questions regarding matplotlib. I’m using it to make a 3d

plot, displaying a surface, it’s contour map, a line climbing the surface

and its projection onto the contour map.

http://old.nabble.com/file/p34015720/landscape_draft.png landscape_draft.png

As you can see, when the lines cross the contourf, they are somewhat

obscured. Before I made the contourf transparent, the lines were blocked,

even though they were above the contour plot when I viewed the picture from

a different angle. Can this be fixed? I want the lines to appear on top of

the contour plot.

Unfortunately, no. Matplotlib was originally designed as a 2D layering renderer. The mplot3d toolkit tries to work within that framework, but in the end, each artist object has to be represented by a single 3rd dimension coordinate (the layer), and so when two artists share bounding box regions, physically incorrect results will happen. Please see this FAQ:

http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles

Also, I am trying to extend the z axis to be lower. This is most of the code

I’m using:

fig=plt.figure(1)

ax=fig.gca(projection=‘3d’)

x=np.arange(0,2.5,.02)

y=np.arange(0,2.3,.02)

x,y=np.meshgrid(x,y)

ax.plot_surface(x,y,Z(x,y),alpha=0.3)

cset=ax.contourf(x,y,Z(x,y),zdir=‘z’,offset=-2,

cmap=plt.cm.jet,levels=np.linspace(0,9,100),alpha=0.5)

ax.set_xlabel(‘x’)

ax.set_ylabel(‘y’)

ax.set_zlim(-2,8) #This is where I try to change the z axis limits.

plt.show()

I’m excluding the code which plots the lines. ax.set_zlim doesn’t do

anything; why is this?

That would depend on which version of matplotlib you are using. The v1.1.x branch should have that working properly.

Cheers!
Ben Root

···

On Fri, Jun 15, 2012 at 8:47 AM, ananduri <arun.nanduri@…287…> wrote:

Thanks Ben and Francesco. The zorder option didn't work, I'll use mayavi or
try to make it work as is. And as for setting the z axis limits, I found
that that line has to be placed after all plotting commands in the script.

Benjamin Root-2 wrote:

···

Ananduri,

On Fri, Jun 15, 2012 at 8:47 AM, ananduri <arun.nanduri@...287...> wrote:

Hello,

I have some minor questions regarding matplotlib. I'm using it to make a
3d
plot, displaying a surface, it's contour map, a line climbing the surface
and its projection onto the contour map.

http://old.nabble.com/file/p34015720/landscape_draft.pnglandscape_draft.png

As you can see, when the lines cross the contourf, they are somewhat
obscured. Before I made the contourf transparent, the lines were blocked,
even though they were above the contour plot when I viewed the picture
from
a different angle. Can this be fixed? I want the lines to appear on top
of
the contour plot.

Unfortunately, no. Matplotlib was originally designed as a 2D layering
renderer. The mplot3d toolkit tries to work within that framework, but in
the end, each artist object has to be represented by a single 3rd
dimension
coordinate (the layer), and so when two artists share bounding box
regions,
physically incorrect results will happen. Please see this FAQ:

http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles

Also, I am trying to extend the z axis to be lower. This is most of the
code
I'm using:

fig=plt.figure(1)
ax=fig.gca(projection='3d')

x=np.arange(0,2.5,.02)
y=np.arange(0,2.3,.02)
x,y=np.meshgrid(x,y)

ax.plot_surface(x,y,Z(x,y),alpha=0.3)

cset=ax.contourf(x,y,Z(x,y),zdir='z',offset=-2,
cmap=plt.cm.jet,levels=np.linspace(0,9,100),alpha=0.5)

ax.set_xlabel('x')
ax.set_ylabel('y')

ax.set_zlim(-2,8) #This is where I try to change the z axis limits.

plt.show()

I'm excluding the code which plots the lines. ax.set_zlim doesn't do
anything; why is this?

That would depend on which version of matplotlib you are using. The
v1.1.x
branch should have that working properly.

Cheers!
Ben Root

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/3d-contourf-and-ax.set-tp34015720p34024704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.