Debian Codegraph @

texmf-dist/doc/metapost/featpost/example/graphs.mp

raw
1 % graphs.mp
2 % L. Nobre G.
3 % 2007
4
5 verbatimtex
6 \documentclass{article}
7 \usepackage{color,SIunits}
8 \begin{document}
9 etex
10
11 input graph;
12
13 beginfig(1);
14 picture thegraph, thedash, thestar;
15 path thecurve;
16 pen thepen;
17 numeric theu;
18 theu = 1.7cm;
19 z1 = (1,2);
20 z2 = (3,8);
21 z3 = (4,8);
22 z4 = (2,8);
23 z5 = (5,1);
24 z6 = (9,1);
25 z7 = (8,2);
26 z8 = (7,3);
27 z9 = (6,4);
28 thestar = btex $\star$ etex scaled (3.5theu/in);
29 thestar := thestar shifted -(center thestar);
30 thepen = pencircle scaled 2mm;
31 thedash = dashpattern( off 3mm on 1mm off 4mm on 2mm );
32 thecurve = z1..z2..z3..z4..z5..z6..z7..z8..z9;
33 thegraph = begingraph(6theu,4theu);
34 glabel.bot( btex $\unit{t}{/\;\second}$ etex, OUT );
35 glabel.lft( btex $\unit{v}{/\;\metre\per\second}$ etex, OUT );
36 gdraw thecurve withpen thepen withcolor blue dashed thedash;
37 gdraw thecurve plot thestar;
38 autogrid(grid.bot,grid.lft) withcolor red dashed evenly;
39 endgraph;
40 draw thegraph;
41 endfig;
42
43 beginfig(2);
44 draw begingraph(7cm,5cm);
45 pickup pencircle scaled 1pt;
46 path p;
47 for x = -20 step 0.2 until -0.2:
48 augment.p (x, sind(x*180/3.14159)/x);
49 endfor
50 augment.p (0, 1);
51 for x = 0.2 step 0.2 until 20:
52 augment.p (x, sind(x*180/3.14159)/x);
53 endfor
54 glabel.lrt (btex $\frac{\sin(x)}{x}$ etex, (-20,1));
55 gdraw p;
56 endgraph;
57 endfig;
58
59 verbatimtex
60 \end{document}
61 etex
62
63 end.
64
65