Alexander,

There is a lot of plots you can do with Metapost. Ordinary, every day stuff. For example:

beginfig(1);

% initialize a and c for f(x)=|x-a| and g(x)=c
numeric a, c;
a=-2;
c=2;

% initialize function label abcissas and postions
numeric flabel, glabel;
flabel:=-5;
glabel:=-5;

% define function f(x)=|x-a|
vardef f(expr x)=
    abs(x-a)
enddef;

% draw line with given point and slope
path F;
F:=(-5,f(-5));
for x=-5 step 1 until 5:
    F:=F--(x,f(x));
endfor;

% initialize scale
numeric u; 10u=4cm;

% the line
F:=F scaled 1u;
draw F withcolor blue;

% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;

% clip and save current picture
picture pic;
clip currentpicture to cpath;
pic:=currentpicture;

% erase currentpicture
currentpicture:=nullpicture;

% draw grid
for k=-5u step 1u until 5u:
    draw (-5u,k)--(5u,k) withcolor 0.85white;
    draw (k,-5u)--(k,5u) withcolor 0.85white;
endfor;

% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);

% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));

% redraw line
draw pic;

% label the functions f(x)=|x-a| and g(x)=c
pair D, E;
D:=(-5,f(-5)) scaled u;
label.lft(btex $f$ etex,D);
E:=(-5,2) scaled u;
label.lft(btex $g$ etex, E);

% draw the graph of g(x)=c
path G;
G:=(-5,2)--(5,2);
G:=G scaled u;
draw G withcolor blue;

endfig;

end.

And for a good stats package, see:

http://www-math.univ-poitiers.fr/~phan/statsmac.html

And for good circuits diagrams, see:

http://www.cnm.es/~pserra/schema/whatis.html

Don't give up on Metapost too soon. It's an awesome language and the file size created are small, a plus when you're document includes lots of figures and you want it to download in reasonable time on the internet.

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to