Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a list {(IC,s,FK)}, which I use to generate a 3d-plot with the help of the command ListPlot3D. IC and s go from 0 to 1.

enter image description here

There is an area (lets say 0.11 < IC < 0.3, 0.1 < s < 0.4) which is specially important, because this is the physical range. For some reason I want to plot the whole parameter space, but highlight (for example with a red rectangle) this physical range. It would be great to frame the physical range with a red rectangle on the surface of the 3d-Plot. (In the end, this 2d-rectangle should look similar to these mesh lines, but it should frame the range, defined above).

Do you have any idea?

share|improve this question
1  
Please include a self contained example (code) of what you're trying to do. –  rm -rf Dec 7 '12 at 21:23
    
{(x,y,z)} isn't valid syntax –  Sjoerd C. de Vries Dec 7 '12 at 21:33
    
I took as guess as to what you want and posted below. If it is not correct please use that as a reference to explain what you do want. –  Mr.Wizard Dec 7 '12 at 21:49
    
I wouldn't try to place a 2D unfilled rectangle parallel to the xy-plane to mark the domain of interest. It would be hard to make it both visible and easy to relate to the data. I think I'd go for superimposing a sub-plot of the same data with different coloring over the domain of interest. Wish I could work this out and post it, but I don't think I'll find the time. –  m_goldberg Dec 8 '12 at 0:35
add comment

4 Answers 4

up vote 8 down vote accepted

With

 data = Table[{x = RandomReal[{-1, 1}], y = RandomReal[{-1, 1}], x^2 - y^2}, {300}];

Three possible methods are

  1. using ColorFunction
  2. using a combination of Mesh, MeshFunctions and MeshShading, (or, and better yet, just Mesh and MeshShading as in @Brett's answer)
  3. produce two plots using different RegionFunction settings and combine them using Show.

Using ColorFunction:

 ListPlot3D[data, BoxRatios -> Automatic, Mesh -> None, 
  ColorFunction -> Function[{x, y, z}, If[-.5 < x < .5 && -.3 < y < .1, Red, White]],
  ColorFunctionScaling -> False, BoxRatios -> Automatic, 
   MaxPlotPoints -> 100, Lighting -> "Neutral"]

enter image description here

or with a different setting for the ColorFunction, say:

 ColorFunction -> Function[{x, y, z}, If[-.5 < x < .5 && -.3 < y < .1,
    ColorData["DeepSeaColors", (1 + x)/2], Directive[Opacity[.7], Hue[(1 + z)/2]]]]

enter image description here

Using Mesh, MeshFunctions and MeshShading:

 ListPlot3D[data,
  MeshFunctions -> {Boole[-.5 < #1 < .5 && -.2 < #2 < .75] &}, 
  Mesh -> {{1}},  MeshShading -> {White, Red}, 
  BoxRatios -> Automatic,  MaxPlotPoints -> 100, Lighting -> "Neutral"]

enter image description here

Using RegionFunction and Show:

lp1 = ListPlot3D[data,
    RegionFunction -> (! (-.5 < #1 < .5 && -.2 < #2 < .75) &),
    Mesh -> None, BoxRatios -> 1,
    MaxPlotPoints -> 100, Lighting -> "Neutral",
    ColorFunction -> (Directive[Opacity[.9], Hue[#1]] &), 
    Lighting -> "Neutral",   ImageSize -> 300];
lp2 = ListPlot3D[data,
    RegionFunction -> ((-.5 < #1 < .5 && -.2 < #2 < .75) &),
    Mesh -> None, BoxRatios -> 1,
    MaxPlotPoints -> 100, Lighting -> "Neutral",
    ColorFunction -> (Red &), Lighting -> "Neutral",
    ImageSize -> 300];
    Panel@Row[{lp1, lp2, Show[{lp1, lp2}]}, Spacer[5]]

enter image description here

share|improve this answer
    
lol -- when did that answer get there? +1 –  Mr.Wizard Dec 7 '12 at 22:39
    
@Mr.W, same here - I should learn to reload the page every 30 secs or so :) Thank you for the vote. –  kguler Dec 7 '12 at 23:03
    
Great, thanks a lot! –  Peter Dec 8 '12 at 12:14
    
One last question. I chose solution number one, using 'ColorFunction'. Instead of the color white, I want use my originally blue color. I tried, but could not find the correct Colordata. Do you know it by accident? Would be great! –  Peter Dec 8 '12 at 14:26
    
@Peter, thanks for the accept. You can try using, say, Lighter@Lighter@Lighter@Blue instead of White inside If. But ... I think it is easier to use the second approach to get the Automatic settings working nicely: just change White to Automatic and remove the Lighting option (or set it to Automatic). –  kguler Dec 8 '12 at 23:35
add comment

This can be done with the Mesh family of options.:

dat = Join @@ 
   Table[{x, y, Sin[10 x y]}, {x, 0, 1, 0.05}, {y, 0, 1, 0.05}];

ListPlot3D[dat, Mesh -> {{0.11, 0.3}, {0.1, 0.4}}, MeshStyle -> None, 
 MeshShading -> {{Automatic, Automatic, Automatic}, 
       {Automatic, Directive[Red, Lighting -> "Neutral"], Automatic},   
       {Automatic, Automatic, Automatic}}]

enter image description here

Since your example is in $x-y$ coordinates, we can use the default functions with specific positions, and use MeshStyle -> None to hide the lines (which we probably aren't interested in, in this case.) Then we just have to construct the appropriate setting for MeshShading.

share|improve this answer
    
Great, thanks a lot! –  Peter Dec 8 '12 at 12:13
add comment

Second attempt:

dat = Join @@ Table[{x, y, Sin[10 x y]}, {x, 0, 1, 0.05}, {y, 0, 1, 0.05}];

ListPlot3D[
 dat,
 ColorFunctionScaling -> False,
 ColorFunction -> (If[0.11 < # < 0.3 && 0.1 < #2 < 0.4, Red, Gray] &)
]

Mathematica graphics

One method to clean up the fuzzy edge:

f = Interpolation[dat];

Plot3D[
 f[x, y], {x, 0, 1}, {y, 0, 1},
 ColorFunctionScaling -> False,
 ColorFunction -> (If[0.11 < # < 0.3 && 0.1 < #2 < 0.4, Red, Gray] &),
 PlotPoints -> 100
]

Mathematica graphics

I seem to remember seeing a better one but I cannot recall it.

share|improve this answer
    
Thanks for your fast answer. I am looking for a 2d-area on the surface of the 3d-plot. (Similar like these mesh-lines, but only in a certain area and with another color) –  Peter Dec 7 '12 at 22:23
    
@Peter please see my updated answer and again give feedback. –  Mr.Wizard Dec 7 '12 at 22:34
    
Thanks a lot! Peter –  Peter Dec 9 '12 at 15:07
add comment

My solution is using ListPlot3D twice:

data = Join @@ 
   Table[{x, y, Sin[10 x y]}, {x, 0, 1, 0.05}, {y, 0, 1, 0.05}];

g1 = ListPlot3D[data];
g2 = ListPlot3D[data, Mesh -> None, 
  RegionFunction -> 
   Function[{x, y, z}, 0.11 < x < 0.3 && 0.1 < y < .4], 
  BoundaryStyle -> Directive[Red, Thick], PlotStyle -> None, 
  MaxPlotPoints -> 50]

Show[g1, g2]

enter image description here

share|improve this answer
    
Thanks a lot! Peter –  Peter Dec 9 '12 at 15:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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