Set X,Y,and Z data for a pcolormesh

Hi All,

I wish to make a 3d volume with a series of slices through it. I have X-Z
data at 15 different Y planes. In MATLAB, I would make a pcolor plot, then
set the Z data to the original ydata, and the Y data to a constant. This
works fine.

I would like to achieve a similar result in matplotlib, but I cannot figure
out anyway to do it.

Any help would be appreciated.

James

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Set-X-Y-and-Z-data-for-a-pcolormesh-tp43187.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

If I understand your intent well, then you want to make slices through a 3D volume and show such slice planes.

I’ve always done this with the various functions of an Axes3D instance that allow you to specify the slice position. On the matplotlib examples page, there is a good example that showed me how to do what I wanted (even though I only had a series of 1D data): polys3d_demo.

You could use the same technique with contourf, which is probably closer to what you want. Have a look at this stackoverflow question.

I hope this helps.

···

2014-04-03 6:50 GMT+02:00 james <jarmez@…287…>:

Hi All,

I wish to make a 3d volume with a series of slices through it. I have X-Z

data at 15 different Y planes. In MATLAB, I would make a pcolor plot, then

set the Z data to the original ydata, and the Y data to a constant. This

works fine.

I would like to achieve a similar result in matplotlib, but I cannot figure

out anyway to do it.

Any help would be appreciated.

James

View this message in context: http://matplotlib.1069221.n5.nabble.com/Set-X-Y-and-Z-data-for-a-pcolormesh-tp43187.html

Sent from the matplotlib - users mailing list archive at Nabble.com.



Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

So, you would like to plot a surface, and then have some slices through it? Perhaps you are looking for something like this?
http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html

In your case, I would use the contourf()'s “zdir” argument to set the direction of the slice’s normal vector, and the “offset” argument to set the location of the slice. In this particular example, the three contourf()'s were purposely placed on the edges of the axes, but they can be placed anywhere you want them to be. You will need to supply contourf() with the appropriate surface data to contour.

A word of caution. mplot3d’s rendering is very crude. When you start to intersect planes together, you will very likely get visual artifacts that I tend to refer to as “Escher-like” in that they are physically impossible. If you want true 3d volume rendering, then you may want to take a look at glumpy or vis3d or mayavi2.

I hope that helps!
Ben Root

···

On Thu, Apr 3, 2014 at 12:50 AM, james <jarmez@…287…> wrote:

Hi All,

I wish to make a 3d volume with a series of slices through it. I have X-Z

data at 15 different Y planes. In MATLAB, I would make a pcolor plot, then

set the Z data to the original ydata, and the Y data to a constant. This

works fine.

I would like to achieve a similar result in matplotlib, but I cannot figure

out anyway to do it.

Any help would be appreciated.

James

View this message in context: http://matplotlib.1069221.n5.nabble.com/Set-X-Y-and-Z-data-for-a-pcolormesh-tp43187.html

Sent from the matplotlib - users mailing list archive at Nabble.com.



Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

This worked brilliantly! Thank you so much!

Secondary question now, is this:

I have a contourf and a polygon made with

ax.add_collection3d(a3.art3d.Poly3DCollection(verts, facecolors=[.5,.5,.5], linewidths=1,edgecolor=‘k’,zorder=0))

How do I change it so the contourf is on top of the polygon? By default it seems to plot the polygon on top. I tried zorder but that did nothing.

Ta