summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/m-graph.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/m-graph.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/m-graph.mkiv109
1 files changed, 107 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/context/base/m-graph.mkiv b/Master/texmf-dist/tex/context/base/m-graph.mkiv
index c9223488480..e8aeb237519 100644
--- a/Master/texmf-dist/tex/context/base/m-graph.mkiv
+++ b/Master/texmf-dist/tex/context/base/m-graph.mkiv
@@ -37,8 +37,44 @@
\unexpanded\long\def\MPgraphformat#1#2{\ctxlua{metapost.format_n("#1","#2")}}
+% We could also delegate parsing using lower level plugins.
+
\startMPinclusions
+ % input string ;
+ % input marith ;
input graph.mp ;
+
+ vardef roundd(expr x, d) =
+ if abs d > 4 :
+ if d > 0 :
+ x
+ else :
+ 0
+ fi
+ elseif d > 0 :
+ save i ; i = floor x ;
+ i + round(Ten_to[d]*(x-i))/Ten_to[d]
+ else :
+ round(x/Ten_to[-d])*Ten_to[-d]
+ fi
+ enddef ;
+
+ Ten_to0 = 1 ;
+ Ten_to1 = 10 ;
+ Ten_to2 = 100 ;
+ Ten_to3 = 1000 ;
+ Ten_to4 = 10000 ;
+
+ def sFe_base =
+ enddef ;
+
+ picture Fe_plus ; Fe_plus := btex + etex ;
+
+ vardef format (expr f,x) = dofmt_.Feform_(f,x) enddef ;
+ vardef Mformat (expr f,x) = dofmt_.Meform (f,x) enddef ;
+ vardef formatstr (expr f,x) = dofmt_.Feform_(f,x) enddef ;
+ vardef Mformatstr(expr f,x) = dofmt_.Meform(f,x) enddef ;
+
vardef escaped_format(expr s) =
"" for n=1 upto length(s) : &
if ASCII substring (n,n+1) of s = 37 :
@@ -48,8 +84,9 @@
fi
endfor
enddef ;
+
vardef dofmt_@\#(expr f, x) =
- textext("\MPgraphformat{"&escaped_format(f)&"}{"&(if string x : x else: decimal x fi)&"}")
+ textext("\MPgraphformat{" & escaped_format(f) & "}{" & (if string x : x else: decimal x fi) & "}")
enddef ;
% vardef format(expr f, x) =
@@ -58,6 +95,74 @@
% vardef Mformat(expr f, x) =
% format(f,x)
% enddef;
+
\stopMPinclusions
-\endinput
+\doifnotmode {demo} {\endinput}
+
+\doiffileelse {agepop91.d} {} {\writestatus{graph}{no data files found}\wait\end}
+
+%D The test:
+
+\starttext
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% gdraw "t:/metapost/grphdata/agepop91.d";
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% gdraw "agepop91.d" plot btex $\bullet$ etex;
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+% glabel.bot(btex Age in years etex, OUT);
+% gdraw "agepopm.d";
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+% glabel.bot(btex Age in years etex, OUT);
+% setrange(origin, whatever,whatever);
+% gdraw "agepopm.d";
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(2.3in,2in);
+% setcoords(log,log);
+% glabel.lft(btex Seconds etex,OUT);
+% glabel.bot(btex Matrix size etex,
+% OUT);
+% gdraw "matmul.d" dashed evenly;
+% glabel.ulft(btex Standard etex,8);
+% gdraw "matmul.d";
+% glabel.lrt(btex Strassen etex,7);
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(6.5cm,4.5cm);
+% setrange(80,0, 90,whatever);
+% glabel.bot(btex Year etex, OUT);
+% glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
+% \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
+% gdraw "lead.d" withpen pencircle scaled 1.5pt;
+% autogrid(,otick.lft);
+% setcoords(linear,linear);
+% setrange(80,0, 90,whatever);
+% glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
+% \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
+% gdraw "lead.d";
+% autogrid(otick.bot,otick.rt);
+% endgraph;
+% \stopMPpage
+
+\stoptext