% length of marks for axes
mark=1mm;
% magnitude for picture scaling
m:=1cm;
% Provide a Background to ensure good Contrast
fill for p = (-.6,-.6), (10,-.6), (10,6), (-.6,6):
p*m-- endfor cycle withcolor white;
% y-Axis
drawarrow (0,-.5m)--(0,6m);
% Marks and Numbers on y-Axis, Grid in x-Direction
for i=1 upto 5:
draw (0,i)*m--(10,i)*m withcolor .6white dashed evenly;
draw (-mark,i*m)--(mark,i*m);
label.lft(decimal(i), (-mark,i*m));
endfor;
% x-Axis
drawarrow (-.5m,0)--(10m,0);
% Marks and Numbers on x-Axis, Grid in y-Direction
for i=1 upto 9:
draw (i,0)*m--(i,6)*m withcolor .5white dashed evenly;
draw (i*m,-mark)--(i*m,mark);
label.bot(decimal(i), (i*m,-mark));
endfor;
% Label for x-Axis
label.top(btex $x$ etex, (9.5m,mark));
% Label for y-Axis
% We put a white bounding Box under this Label in Case
% we draw over a Gridline. We do not use 'unfill' because
% that would kick out the background
picture fx;
fx = thelabel.rt (btex $f(x)$ etex, (mark,5.5m));
fill bbox fx withcolor white;
draw fx;
% Label the Graph
label.top(btex $\sqrt x$ etex, (9.5,sqrt(9.5))*m);
% That's why we are here: Draw the Squareroot
linecap:=butt;
draw (
(0,0){0,1}
..(0.25,0.5)*m{1,1}
for i=1 upto 3:
..(i*i,i)*m{2i,1}
endfor
..(10,sqrt(10))*m{2*sqrt(10),1}
) withcolor .5red withpen pencircle scaled 1.2;