size(12cm,0,false); import graph3; import contour; texpreamble("\usepackage{icomma}"); real f(pair z) { return z.x*z.y*exp(-z.x); } bbox3 b=limits((0,0,0),(5,10,4.5)); currentprojection=orthographic(-2.5,-5,1); currentlight=(1,-1,2); aspect(b,1,1,1); xaxis(rotate(X)*Label("$x$",align=project(-b.Y())),b,Ticks(), dir=-b.Y()); yaxis(Label("$y$",align=project(-b.X())),b,Ticks(Step=2), dir=-b.X()); zaxis(Label("$z=xye^{-x}$",align=2E,relative(1.1)),b.Y(),b.YZ(),LeftTicks()); layer(); pen p=rgb(0.2,0.5,0.7); add(surface(f,(0,0),(5,10),100,100,meshpen=nullpen)); layer(); add(surface(f,5,(0,0),(5,10),20,20,nullpen,meshpen=p)); real[] datumz={.5,1,1.5,2,2.5,3,3.5}; pen[] p=sequence(new pen(int i) { return datumz[i]/3.5*red; },7); Label [] L=sequence(new Label(int i) { return scale(0.75)*Label(format("$z=%g$",datumz[i]),align=E,BeginPoint); },7); Label [] legend=sequence(new Label(int i) { return format("$z=%g$",datumz[i]); },7); draw(L,lift(f,contour(f,(0,0),(5,10),datumz)),p,legend); attach(legend(),project((4,6,2)),2E,UnFill);