# How can I convert a 3D contour plot into a region for use as a custom slice in ListSliceDensityPlot3D?

The documentation for ListSliceDensityPlot3D says

ListSliceDensityPlot3D[{{x1,y1,z1,f1},{x2,y2,z2,f2},…},surf] generates a slice density plot for the values $f_i$ at points $\{x_i,y_i,z_i\}$.

But what if my surface is defined only numerically?

list1 = Table[{x, y, z, x^2 + y^2 - z^2}, {x, -1, 1, .05}, {y, -1,
1, .05}, {z, -1, 1, .05}]~Flatten~2;
surface1 = First @ ListContourPlot3D[list1, Contours -> {0.3}];
Graphics3D @ surface1 This seems clearly to be a surface, so let's try to use it in ListSliceDensityPlot3D:

ListSliceDensityPlot3D[
Table[Exp[-3^2 ((x - .3)^2 + (y - .3)^2 + (z - .3)^2)],
{x, -1, 1, .1}, {y, -1, 1, .1}, {z, -1, 1, .1}],
surface1]


I get the error

ListSliceDensityPlot3D::slice: "Slice specification GraphicsComplex[<<1>>] should be a named slice, surface or volume region, or list of slices."

and it uses the default slices Of course in this example I could use ImplicitRegion[x^2 + y^2 - z^2==0.3,{x,y,z}] to define the surface,

ListSliceDensityPlot3D[
Table[Exp[-3^2 ((x - .3)^2 + (y - .3)^2 + (z - .3)^2)],
{x, -1, 1, .1}, {y, -1, 1, .1}, {z, -1, 1, .1}],
ImplicitRegion[x^2 + y^2 - z^2 == 0.3, {x, y, z}],
DataRange -> {{-1, 1}, {-1, 1}, {-1, 1}}] but what if I don't have the equation, but only the data? If I try to define the ImplicitRegion using an interpolation function it does not work.

I can't apply DiscretizeRegion to the contour plot, what can I do to extract the surface?

• I want to have an object that I can use as a surface for ListSliceDensityPlot3D. When I define surf = First@ListContourPlot3D[list1, Contours -> {0.3}] and then try to use it via ListSliceDensityPlot3D[list2, surf] I get the error "Slice specification GraphicsComplex[<<1>>] should be a named slice, surface or volume region, or list of slices." – Jason B. Feb 4 '16 at 10:37
• I will edit it to make it more clear :-) – Jason B. Feb 4 '16 at 10:39
• @Kuba - see this question, which could end up closed even though it is a valid question. Rahul pointed out it could be done with ListSliceDensityPlot3D and I just want to try and do so. – Jason B. Feb 4 '16 at 10:48
• @Kuba, yeah, I know there's a way to do it, I just wonder how far you can go using this new function. Please avoid extended discussions in comments lol – Jason B. Feb 4 '16 at 10:51
• Ahh, right, I though that is something you problably know. Well, the documentation states you can only use regions so the question can be narrowed down to "how to convert contour plot 3d to region". – Kuba Feb 4 '16 at 10:52

One way is to create a region using DiscretizeGraphics.

g = ListContourPlot3D[list1, Contours -> {0.3}]


Now DiscretizeGraphics[g] gets upset and refuses to work because of the GraphicsComplex inside of g. We can get rid of that using Normal, so let's try:

surf = DiscretizeGraphics@Normal[g] It still gets upset because of some directives, but it appears to handle the surface part properly. This is a region so we can use it in SliceDensityPlot3D:

SliceDensityPlot3D[x^2 + y^2 + z^2, surf, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] • Thanks! I didn't try DiscretizeGraphics but it would have failed anyway without Normal. How did you know you would have to use Normal? Experience with this, or more of a workflow: If it fails, try it with Normal – Jason B. Feb 4 '16 at 11:32
• @JasonB The error message says that GraphicsComplex is not supported. Normal expands the GraphicsComplex (see last entry under Details on its documentation page). – Szabolcs Feb 4 '16 at 11:38