3
$\begingroup$

I've done this code:

Plot3D[x + y + 1, {x, 0, 1}, {y, 0, 1},
 RegionFunction -> Function[{x, y, z}, 0 <= y <= Sqrt[x]]]

Producing this image:

enter image description here

In MATLAB, I used the mesh command:

u=linspace(0,1,40);
v=linspace(0,1,40);
[u,v]=meshgrid(u,v);
x=u;
y=v.*sqrt(u);
z=x+y+1;
h=meshz(x,y,z);
Z=get(h,'Zdata');
Z([1 end],:)=0;
Z(:,[1,end])=0;
set(h,'ZData',Z)
xlabel('x-axis')
ylabel('y-axis')

To produce this image:

enter image description here

Is there a Mathematica function that will add the walls to my first image?

$\endgroup$
3
  • 3
    $\begingroup$ Filling -> Bottom? $\endgroup$
    – Kuba
    Nov 6, 2014 at 17:22
  • 1
    $\begingroup$ B´gosh, but that Matlab plot is hard on the eyes! @Kuba that deserves an answer! $\endgroup$
    – Yves Klett
    Nov 6, 2014 at 17:44
  • 1
    $\begingroup$ UnderstatementQ["hard on the eyes"] (*True*) $\endgroup$
    – gpap
    Nov 6, 2014 at 17:47

2 Answers 2

8
$\begingroup$

While I like gpap's solution, it requires quite a bit of work. So, instead, use the built-in options. The important one is FaceGrids which takes a list of vectors which specify which side the grid is on.

Plot3D[x + y + 1, {x, 0, 1}, {y, 0, 1}, 
 RegionFunction -> Function[{x, y, z}, 0 <= y <= Sqrt[x]], 
 FaceGrids -> {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}}, Boxed -> False, 
 Filling -> Bottom, FillingStyle -> Green, ColorFunction -> Hue]

enter image description here

$\endgroup$
4
  • $\begingroup$ Aaaaaargh, facegrids dammit. I faintly remember using this at some point but it's not exactly common. +1 this is far better than mine! $\endgroup$
    – gpap
    Nov 6, 2014 at 18:24
  • $\begingroup$ @rollyer: How can you make the fill drop to the xy-plane (at z=0 instead of at z=1). $\endgroup$
    – David
    Nov 7, 2014 at 2:28
  • $\begingroup$ @David yes, add the option PlotRange -> {0, Automatic} to it. $\endgroup$
    – rcollyer
    Nov 7, 2014 at 2:43
  • 1
    $\begingroup$ Absolutely what I needed for my students. Thank you so much. $\endgroup$
    – David
    Nov 7, 2014 at 4:58
4
$\begingroup$

It will be easy to write a function that operates on the plot and takes the minimum value of each coordinate and adds a plane to combine the plots. I really don't have time to do this for you now so I've just copy-pasted some planes and changed the options to match the (uglier in my opinion) plotting style of MATLAB:

Show[{
  ParametricPlot3D[{0, y, z}, {y, 0, 1}, {z, 1, 3}, 
   PlotStyle -> White, Lighting -> "Neutral"],
  ParametricPlot3D[{x, 1, z}, {x, 0, 1}, {z, 1, 3}, 
   PlotStyle -> White, Lighting -> "Neutral"],
  ParametricPlot3D[{x, y, 1}, {x, 0, 1}, {y, 0, 1}, 
   PlotStyle -> White, Lighting -> "Neutral"],
  Plot3D[{x + y + 1}, {x, 0, 1}, {y, 0, 1}, 
   RegionFunction -> Function[{x, y, z}, 0 <= y <= Sqrt[x]], 
   Mesh -> 90, Filling -> Bottom, ColorFunction -> Hue, 
   FillingStyle -> Directive[Darker@Green, Opacity[1]]]}, 
 PlotRange -> {{0, 1}, {0, 1}, {1, 3}}, BoxRatios -> {2, 2, 1}, 
 Boxed -> False, Background -> LightGray]

enter image description here

As I said, I can automate this but it'll have to wait until later/tomorrow if the above isn't satisfactory.

$\endgroup$

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.