summaryrefslogtreecommitdiff
path: root/tex/context/base/m-graph.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/m-graph.tex')
-rw-r--r--tex/context/base/m-graph.tex175
1 files changed, 175 insertions, 0 deletions
diff --git a/tex/context/base/m-graph.tex b/tex/context/base/m-graph.tex
new file mode 100644
index 000000000..6f71cca3c
--- /dev/null
+++ b/tex/context/base/m-graph.tex
@@ -0,0 +1,175 @@
+%D \module
+%D [ file=m-graph,
+%D version=2000.08.06,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=\METAPOST\ graph module support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\loadmarkfile{m-graph}
+
+\doifnotmode {demo} {\endinput}
+
+%D You need to have the data files in your path,
+%D otherwise the run is aborted.
+
+\doiffileelse {agepop91.d} {} {\writestatus{graph}{no data files found}\wait\end}
+
+%D The test:
+
+\starttext
+
+\startMPpage
+draw begingraph(3in,2in);
+ gdraw "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
+
+% No longer needed, since John will fix it.
+%
+% %D For the moment we need the following patch. Adam T. Lindsay
+% %D found out that the following code produced an error:
+% %D
+% %D \starttyping
+% %D \startMPcode
+% %D draw begingraph(130mm,35mm);
+% %D setrange(0,0,10,22000);
+% %D glabel.lft(btex {correct 0--22000} etex rotated 90, OUT);
+% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
+% %D endgraph;
+% %D \stopMPcode
+% %D
+% %D \startMPcode
+% %D draw begingraph(130mm,35mm);
+% %D setrange(0,50,10,22000);
+% %D glabel.lft(btex {wrong 50--22000} etex rotated 90, OUT);
+% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
+% %D endgraph;
+% %D \stopMPcode
+% %D
+% %D \startMPcode
+% %D draw begingraph(130mm,35mm);
+% %D setrange(0,110,10,30000);
+% %D glabel.lft(btex {failed 110--22000} etex rotated 90, OUT);
+% %D autogrid(itick.bot,grid.lft) withcolor .75white ;
+% %D endgraph;
+% %D \stopMPcode
+% %D \stoptyping
+% %D
+% %D The bug is a rather nasty one and needs some tweaking in
+% %D the low level graph code. John Hobby suggested for the
+% %D moment to initialize \type {setrange} as follows:
+% %D
+% %D \starttyping
+% %D setrange(0,0,"22000","22000")
+% %D \stoptyping
+% %D
+% %D Folowing this suggesion, I provide the following
+% %D extension:
+
+% def begingraph(expr w, h) =
+% begingroup
+% save X_, Y_, Gfin_, Gcur_, Gcbb_, Gneedgr_, Gneedfr_, Gdidsc_;
+% save Gdpic_, Gppic_, Ggl_, Garw_;
+% picture Gfin_, Gcur_, Gcbb_, Gdpic_, Gppic_, Ggl_[];
+% boolean Gneedgr_, Gneedfr_, Gdidsc_;
+% Gfin_ = nullpicture;
+% Gcur_ = nullpicture;
+% Gcbb_ = nullpicture;
+% X_.ctyp = Y_.ctyp = linear;
+% Z_.gdim = (w,h);
+% X_.sc = Y_.sc = 0;
+% Gneedgr_ = true;
+% Gneedfr_ = true;
+% Gdidsc_ = false;
+% Gdpic_ = nullpicture;
+% Garw_ = 0;
+% scantokens everybegingraph ;
+% enddef;
+%
+% boolean fixsetrange ; fixsetrange := true ;
+%
+% vardef dosetrange(text t) =
+% interim warningcheck:=0;
+% save r_; r_=0;
+% string r_[]s;
+% for x_=
+% for p_=t: if pair p_: xpart p_, ypart fi p_, endfor:
+% r_[incr r_] if string x_: s fi = x_;
+% if r_>2:
+% Gsetr_ if r_=3: X_(Gxcvlin_) else: Y_(Gycvlin_) fi(
+% r_[r_-2] if unknown r_[r_-2]: s fi, x_);
+% fi
+% exitif r_=4;
+% endfor
+% enddef;
+%
+% vardef setrange(text t) =
+% if fixsetrange : dosetrange(0,0,20000,20000) ; fi ;
+% dosetrange(t) ;
+% enddef ;
+%
+% if unknown everybegingraph :
+% string everybegingraph ;
+% % everybegingraph := "setrange(0,0,20000,20000)" ;
+% fi ;