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
.
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?
Answer
With
data = Table[{x = RandomReal[{-1, 1}], y = RandomReal[{-1, 1}], x^2 - y^2}, {300}];
Three possible methods are
- using
ColorFunction
- using a combination of
Mesh
,MeshFunctions
andMeshShading
, (or, and better yet, justMesh
andMeshShading
as in @Brett's answer) - produce two plots using different
RegionFunction
settings and combine them usingShow
.
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"]
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]]]]
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"]
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]]
Comments
Post a Comment