-1

Is it possible to create a picture that would look like this?

I have solved a problem that also asks to draw a similar picture. Don't want to ruin my document by inserting a picture of the drawing by hand (see below). Any insight is greatly appreciated.

enter image description here

enter image description here

Olga
  • 480

1 Answers1

2

Here's a first attempt in plain Metapost, although it is not really the best tool for doing three-dimensional charts.

enter image description here

The chart is a bit "fragile" - for example if you alter the rotation in the transformation, you will need to fiddle with the slant of the normal curve to make it look right. The values below were determined by trial-and-correction.

prologues := 3;
outputtemplate := "%j%c.eps";

stp = 2.50662827463;
vardef gauss(expr mu,sigma,x) = 
   if abs(x-mu) < 4sigma:
     mexp(-128*(((x-mu)/sigma)**2))/stp/sigma
   else: 
     0 
   fi 
   enddef;

vardef gauss_curve(expr mu, sigma, a, b, s) = 
  (a,gauss(mu,sigma,a)) for x=a+s step s until b: .. (x,gauss(mu,sigma,x)) endfor
  enddef;

beginfig(1);
path xx, yy;
u = 1.6mm; v = 0.1mm;
transform t; t = identity rotated -35;
xx = origin -- (50u,0);
yy = origin -- (0,500v) transformed t;

drawarrow xx; drawarrow yy; 
label.rt (btex $x$ etex, point infinity of xx);
label.top(btex $y$ etex, point infinity of yy);

for x=10 step 10 until 40: 
  draw yy shifted (x*u,0) withcolor .8 white;
  draw (up--down) transformed t shifted (x*u,0);
  label.bot(decimal x, (x*u,0));
  endfor

for y=100 step 100 until 400:
  draw xx shifted ((0,y*v) transformed t) withcolor .8 white;
  draw (left--right) shifted ((0,y*v) transformed t);
  label.lft(decimal y,        (0,y*v) transformed t);
  endfor

path fit; fit = (0,225v) transformed t shifted (5u,0)  
             -- (0,425v) transformed t shifted (45u,0);

draw fit withcolor .67 red;

for x=10,20,40:
  draw gauss_curve(0,1,-2.5,+2.5,.1) slanted 3.6 rotated 90 xscaled 30 yscaled 10
       transformed t
       shifted ((0,(200+5x)*v) transformed t) shifted (x*u,0)
       withcolor .6 white + .2 red;

   draw (origin -- 20 up) 
       shifted ((0,(200+5x)*v) transformed t) shifted (x*u,0)
       withcolor .6 white + .2 red;
endfor
endfig;
end.
Thruston
  • 42,268