1
$\begingroup$

I am interested in the plot of the 3 hump function $f(x)= 2x^2 - 1.05x^4 +\frac{x^6}{6}+xy+y^2$ , for $x,y\in[-2,2]$.

So in order to show the 3 humps of the respective plot I gave the following three inputs like this:

p = Show[Plot3D[2 x^2-1.05 x^4+x^6/6+x y+y^2,{x,-2,2.2},{y,-1/5,1/5},PlotRange->All,AxesLabel->Automatic,Mesh->5,PlotLabel->" z=2 x^2-1.05 x^4+x^6/6+x y+y^2 (Three-Hump Camel function) ",PlotTheme->"Web",BoundaryStyle->Directive[Black,Thick]],ListPointPlot3D[{{0,0,0}}->{"{0, 0, 0}"},LabelingFunction->Bottom]]
s = Plot3D[z=0.6,{x,-2,2},{y,-1/5,1/5},AxesLabel->{x,y,z},Mesh->3,ColorFunctionScaling->True,ColorFunction->"TemperatureMap"]
Show[p,s]

But I am not so happy with that. I would like my final Plot to look like an object cut in three pieces by an invisible knife and these pieces are separated a small distance from each other. Can you advise me how to do that? Thanks

$\endgroup$
  • 2
    $\begingroup$ maybe something like Plot3D[2 x^2 - 1.05 x^4 + x^6/6 + x y + y^2, {x, -2, 2.2}, {y, -1/5, 1/5}, PlotRange -> All, MeshFunctions -> {#3 &}, Mesh -> {{0.6}}, MeshStyle -> Directive[Thin, Dashed, White], BoundaryStyle -> Directive[Black, Thick]]? $\endgroup$ – kglr Nov 6 '19 at 16:45
1
$\begingroup$

You can use a combination of options MeshFunctions, Mesh and MeshStyle:

Plot3D[2 x^2 - 1.05 x^4 + x^6/6 + x y + y^2, {x, -2, 2.2}, {y, -1/5, 1/5},
 PlotRange -> All, 
 MeshFunctions -> {#3 &}, 
 Mesh -> {{0.6}}, 
 MeshStyle -> Directive[Thin, White], 
 BoundaryStyle -> Directive[Black, Thick]] 

enter image description here

To add additional mesh lines as in OP you can use multiple mesh functions:

Plot3D[2 x^2 - 1.05 x^4 + x^6/6 + x y + y^2, {x, -2, 2.2}, {y, -1/5, 1/5}, 
 PlotRange -> All, 
 MeshFunctions -> {#3 &, #3 &}, 
 Mesh -> {{0.6}, 3}, 
 MeshStyle -> {Directive[Thin, White], Gray}, 
 BoundaryStyle -> Directive[Black, Thick]] 

enter image description here

Alternatively, you can use a combination of options Exclusions and ExclusionsStyle:

Plot3D[2 x^2 - 1.05 x^4 + x^6/6 + x y + y^2, {x, -2, 2.2}, {y, -1/5, 1/5}, 
 PlotRange -> All, 
 Exclusions -> {2 x^2 - 1.05 x^4 + x^6/6 + x y + y^2 == .6}, 
 ExclusionsStyle -> Directive[Thin, White], 
 Mesh -> 3, 
 PlotTheme -> "Web", 
 BoundaryStyle -> Directive[Black, Thick]] 

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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