m-graph.mkiv /size: 4423 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=m-graph,
3%D        version=2008.09.08,
4%D          title=\CONTEXT\ Extra Modules,
5%D       subtitle=\METAPOST\ graph module support,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14% We just assume lua specification instead of the graph ones that
15% are limited by what mp can do. We support @ as replacement for
16% the percent symbol. We also add a specifier when no one is given.
17
18\unprotect
19
20\defineMPinstance
21  [graph]
22  [\s!format=metafun,
23   \s!extensions=\v!yes,
24   \s!initializations=\v!yes,
25   \c!method=\s!double]
26
27\startMPdefinitions{graph}
28    loadmodule "grap" ;
29%     input mp-grap.mpiv ;
30\stopMPdefinitions
31
32\protect
33
34\continueifinputfile{m-graph.mkiv}
35
36%D We put this test here as in \type {meta-tex.mkiv} it would abort due to redefinition
37%D of namespaces.
38
39\starttext
40
41\startMPpage[instance=graph]
42    label.rt(format("@g","1e-8"),  (0,       0)) ;
43    label.rt(format("@g","1e+8"),  (2cm,     0)) ;
44    label.rt(format("@g","1e-10"), (0,  -0.5cm)) ;
45    label.rt(format("@g","1e+10"), (2cm,-0.5cm)) ;
46    label.rt(format("@g","1e-12"), (0,  -1.0cm)) ;
47    label.rt(format("@g","1e+12"), (2cm,-1.0cm)) ;
48    label.rt(format("@g","1e-0"),  (0,  -1.5cm)) ;
49    label.rt(format("@g","1e+0"),  (2cm,-1.5cm)) ;
50    label.rt(format("@g","1"),     (0,  -2.0cm)) ;
51    label.rt(format("@g","1"),     (2cm,-2.0cm)) ;
52    label.rt(format("@g","1e-102"),(0,  -2.5cm)) ;
53    label.rt(format("@g","1e+102"),(2cm,-2.5cm)) ;
54    currentpicture := currentpicture shifted (-4cm,0) ;
55    %
56    label.rt(format("@j","1e-8"),  (0,       0)) ;
57    label.rt(format("@j","1e+8"),  (2cm,     0)) ;
58    label.rt(format("@j","1e-10"), (0,  -0.5cm)) ;
59    label.rt(format("@j","1e+10"), (2cm,-0.5cm)) ;
60    label.rt(format("@j","1e-12"), (0,  -1.0cm)) ;
61    label.rt(format("@j","1e+12"), (2cm,-1.0cm)) ;
62    label.rt(format("@j","1e-0"),  (0,  -1.5cm)) ;
63    label.rt(format("@j","1e+0"),  (2cm,-1.5cm)) ;
64    label.rt(format("@j","1"),     (0,  -2.0cm)) ;
65    label.rt(format("@j","1"),     (2cm,-2.0cm)) ;
66    label.rt(format("@j","1e-102"),(0,  -2.5cm)) ;
67    label.rt(format("@j","1e+102"),(2cm,-2.5cm)) ;
68    label.rt(formatted("(@f,@f)",(1.23,4.56)),(0cm,-3.0cm)) ;
69    label.rt(formatted("(@i,@i)",(1.23,4.56)),(0cm,-3.5cm)) ;
70    label.rt(formatted("(@g,@g)",(1.23,4.56)),(0cm,-4.0cm)) ;
71    label.rt(formatted("(@e,@e)",(1.23,4.56)),(0cm,-4.5cm)) ;
72    label.rt(formatted("(@j,@j)",(1.23,4.56)),(0cm,-5.0cm)) ;
73\stopMPpage
74
75% \startMPpage[instance=graph]
76% draw begingraph(3in,2in);
77%     gdraw "t:/metapost/grphdata/agepop91.d";
78% endgraph;
79% \stopMPpage
80
81% \startMPpage[instance=graph]
82% draw begingraph(3in,2in);
83%     gdraw "agepop91.d" plot btex $\bullet$ etex;
84% endgraph;
85% \stopMPpage
86
87% \startMPpage[instance=graph]
88% draw begingraph(3in,2in);
89%     glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
90%     glabel.bot(btex Age in years etex, OUT);
91%     gdraw "agepopm.d";
92% endgraph;
93% \stopMPpage
94
95% \startMPpage[instance=graph]
96% draw begingraph(3in,2in);
97%     glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
98%     glabel.bot(btex Age in years etex, OUT);
99%     setrange(origin, whatever,whatever);
100%     gdraw "agepopm.d";
101% endgraph;
102% \stopMPpage
103
104% \startMPpage[instance=graph]
105% draw begingraph(2.3in,2in);
106%     setcoords(log,log);
107%     glabel.lft(btex Seconds etex,OUT);
108%     glabel.bot(btex Matrix size etex,
109%     OUT);
110%     gdraw "matmul.d" dashed evenly;
111%     glabel.ulft(btex Standard etex,8);
112%     gdraw "matmul.d";
113%     glabel.lrt(btex Strassen etex,7);
114% endgraph;
115% \stopMPpage
116
117% \startMPpage[instance=graph]
118% draw begingraph(6.5cm,4.5cm);
119%     setrange(80,0, 90,whatever);
120%     glabel.bot(btex Year etex, OUT);
121%     glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
122%     \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
123%     gdraw "lead.d" withpen pencircle scaled 1.5pt;
124%     autogrid(,otick.lft);
125%     setcoords(linear,linear);
126%     setrange(80,0, 90,whatever);
127%     glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
128%     \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
129%     gdraw "lead.d";
130%     autogrid(otick.bot,otick.rt);
131% endgraph;
132% \stopMPpage
133
134\stoptext
135