6
$\begingroup$

I am having trouble getting contour lines on a 3D plot (ListPlot3D). I have tried ListContourPlot3D, but that gives me a really weird looking graph with a ton of dfferent levels. What I would like is to get Contour lines on my ListPlot3D so it looks like a topo-map or something. As of now I have a contour map and a 3D plot - in essence I would like to combine them. Here is what the notebook currently looks like: enter image description here

$\endgroup$
1

2 Answers 2

14
$\begingroup$

You are looking for MeshFunctions -> {#3 &}. The documentation for MeshFunctions lays out what values are accessible by a plot that uses MeshFunctions and its defaults in the Details section.

As to why ListContourPlot3D was not working for this: its purpose is entirely different. It is intended to draw contours for an $\mathbb{R}^3 \to \mathbb{R}$ function, such as $f(x, y, z) = x^2 + y^2 - z^2$.

$\endgroup$
4
  • 1
    $\begingroup$ This is an unusual URL: wolfram.com/xid/0i1q1qqc4-mvz -- where did it come from? $\endgroup$
    – Mr.Wizard
    Commented Jan 25, 2013 at 21:32
  • 2
    $\begingroup$ @Mr.Wizard on the examples, click on the "In" and the URL is in the pop-up. Rm pointed out how to do it awhile back. $\endgroup$
    – rcollyer
    Commented Jan 25, 2013 at 23:54
  • $\begingroup$ @Mr.Wizard you get an empty pop-up where? on the website? $\endgroup$
    – rcollyer
    Commented Jan 25, 2013 at 23:56
  • $\begingroup$ It seems I misunderstood. I thought this was in the help Notebooks but I see it is on the Web copy. I knew that the code was there to copy but I've never noticed the URL at the bottom. Thanks! $\endgroup$
    – Mr.Wizard
    Commented Jan 25, 2013 at 23:58
4
$\begingroup$

Here is a method to obtain nice 2D contour plots using the Presentations Application (which I have a propriatary interest in). I don't have access to your data so I am using a regular function as an example.

<< Presentations`

Draw3DItems[
 {ContourDraw[Sin[x] + Sin[y], {x, -5, 5}, {y, -5, 5},
    ColorFunction -> ColorData["StarryNightColors"]] // 
   RaiseTo3D[Sin[#1] + Sin[#2] &]},
 NeutralLighting[0, .5, .1],
 NiceRotation,
 ImageSize -> 400]

The Presentations drawing commands allow us to deal directly with the graphics primitives and RaiseTo3D is a Presentations routine that does what it says. NaturalLighting is similar to the Mathematica Neutral Lighting, but gives much more control. NiceRotation gives mouse rotations without jumpings. Here is the graphic:

enter image description here

And in the notebook the contour lines even have Tooltips.

$\endgroup$
2
  • $\begingroup$ How is this better than the default methods? Here you have to enter the function twice. Isn't it easier to just use Plot3D[Sin[x] + Sin[y], {x, -5, 5}, {y, -5, 5}, MeshFunctions -> {#3 &}, Mesh -> 7, ColorFunction -> ColorData["StarryNightColors"]] ? $\endgroup$
    – Mr.Wizard
    Commented Jan 28, 2013 at 19:37
  • 1
    $\begingroup$ @Mr.Wizard There are two things that are better. This is a true contour plot with distinct colors between the contours. Also, using a true contour plot, it is possible to better specify the contour values and obtain distinct coloring in each region using the ContourColors function in Presentations. For example, one might want a number of closely valued contour lines in a plateau region. The Mesh method has mesh lines on top of a general shading. Secondly, the contours have tooltips, whereas the Mesh lines don't. I agree that for many cases the Mesh method might be sufficient. $\endgroup$
    – David Park
    Commented Jan 28, 2013 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.