m-graph.mkiv /size: 4361 b    last modification: 2025-02-21 11:03
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("(@r,@r)",(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\stopMPpage
73
74% \startMPpage[instance=graph]
75% draw begingraph(3in,2in);
76%     gdraw "t:/metapost/grphdata/agepop91.d";
77% endgraph;
78% \stopMPpage
79
80% \startMPpage[instance=graph]
81% draw begingraph(3in,2in);
82%     gdraw "agepop91.d" plot btex $\bullet$ etex;
83% endgraph;
84% \stopMPpage
85
86% \startMPpage[instance=graph]
87% draw begingraph(3in,2in);
88%     glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
89%     glabel.bot(btex Age in years etex, OUT);
90%     gdraw "agepopm.d";
91% endgraph;
92% \stopMPpage
93
94% \startMPpage[instance=graph]
95% draw begingraph(3in,2in);
96%     glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
97%     glabel.bot(btex Age in years etex, OUT);
98%     setrange(origin, whatever,whatever);
99%     gdraw "agepopm.d";
100% endgraph;
101% \stopMPpage
102
103% \startMPpage[instance=graph]
104% draw begingraph(2.3in,2in);
105%     setcoords(log,log);
106%     glabel.lft(btex Seconds etex,OUT);
107%     glabel.bot(btex Matrix size etex,
108%     OUT);
109%     gdraw "matmul.d" dashed evenly;
110%     glabel.ulft(btex Standard etex,8);
111%     gdraw "matmul.d";
112%     glabel.lrt(btex Strassen etex,7);
113% endgraph;
114% \stopMPpage
115
116% \startMPpage[instance=graph]
117% draw begingraph(6.5cm,4.5cm);
118%     setrange(80,0, 90,whatever);
119%     glabel.bot(btex Year etex, OUT);
120%     glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
121%     \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
122%     gdraw "lead.d" withpen pencircle scaled 1.5pt;
123%     autogrid(,otick.lft);
124%     setcoords(linear,linear);
125%     setrange(80,0, 90,whatever);
126%     glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
127%     \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
128%     gdraw "lead.d";
129%     autogrid(otick.bot,otick.rt);
130% endgraph;
131% \stopMPpage
132
133\stoptext
134