verbatimtex %&latex % necessary for \, \documentclass{article} \usepackage{color} \usepackage{times} \begin{document} etex defaultfont:="ptmr8r"; input graph; color diacol[]; diacol1 := (.648,.3,.3); diacol2 := (.41,.51,.89); diacol3 := (.29,.66,.29); diacol4 := (.48,.29,.66); def diamond(expr c) = save w; w := 1.4; path p; p := (0,w)--(w,0)--(0,-w)--(-w,0)--cycle; fill p withcolor c; draw p withpen pencircle scaled .3; enddef; def dtriangle(expr c) = save w; w := 1.4; path p; p := (-w,w)--(w,w)--(0,-w)--cycle; fill p withcolor c; draw p withpen pencircle scaled .3; enddef; def utriangle(expr c) = save w; w := 1.4; path p; p := (-w,-w)--(w,-w)--(0,w)--cycle; fill p withcolor c; draw p withpen pencircle scaled .3; enddef; def rtriangle(expr c) = save w; w := 1.4; path p; p := (-w,-w)--(-w,w)--(w,0)--cycle; fill p withcolor c; draw p withpen pencircle scaled .3; enddef; def filledsq(expr c) = save w; w := 2; path p; p := (-w,-w)--(-w,w)--(w,w)--(w,-w)--cycle; fill p withcolor c; draw p withpen pencircle scaled .3; enddef; vardef poweroftwo primary x = write "btex $2^{"&decimal(x)&"}$ etex" to "tttmp.mp"; write EOF to "tttmp.mp"; scantokens "input tttmp" enddef; path Gtemplate.minorotick; Gtemplate.minorotick = (-3bp,0)--origin; vardef minorotick@#(expr u) text w = Gtlab_(@#,@,false,"",u,w); enddef; beginfig(1) picture diasym[]; diamond(diacol1); diasym1 := currentpicture; clearit; dtriangle(diacol2); diasym2 := currentpicture; clearit; utriangle(diacol3); diasym3 := currentpicture; clearit; rtriangle(diacol4); diasym4 := currentpicture; clearit; save n; n := 4; save gr; picture gr; gr := begingraph(2.4in,2in) setcoords(linear,linear); setrange(10,0,29,350); fill unitsquare xscaled X_.gdim yscaled Y_.gdim withcolor .9white; for y=0 step 50 until 350: grid.lft(format("%g",y), y) withcolor .6white; endfor for x=10 upto 29: minorotick.bot(x); endfor for x=10 step 3 until 28: otick.bot(poweroftwo x, x); endfor frame.llft; path p[]; gdata("data1.d", $, for j=1 upto n: augment.p[j]($1, $[j+1]); endfor); for j=1 upto n: gdraw p[j] withcolor diacol[j]; gdraw p[j] plot diasym[j]; endfor glabel.bot(btex \textbf{\sf X-Axis Description} etex, OUT); glabel.lft(btex \textbf{\sf Y-Axis Description} etex rotated(90), OUT); endgraph; draw gr; picture lab[]; lab1 = btex \sf\scriptsize Legend1 etex; lab2 = btex \sf\scriptsize Legend2 etex; lab3 = btex \sf\scriptsize Legend2 etex; lab4 = btex \sf\scriptsize Legend4 etex; picture legend; legend := nullpicture; for j=1 upto n: picture legendlab; legendlab := diasym[j]; addto legendlab also lab[j] shifted (lrcorner diasym[j]-llcorner diasym[j] - ((ulcorner lab[j]-llcorner lab[j]) - (ulcorner diasym[j]-llcorner diasym[j]))); pair lsh; lsh := lrcorner legend-llcorner legend; if j > 1: lsh := lsh + (lrcorner diasym[j] - llcorner diasym[j]); fi addto legend also legendlab shifted lsh; endfor pair sh; sh := .5(lrcorner gr + llcorner gr)+(0,-10)-.5(lrcorner legend+llcorner legend); fill bbox legend shifted sh withcolor .9white; draw bbox legend shifted sh; draw legend shifted sh; endfig; beginfig(2) picture colsq[]; filledsq(diacol1); colsq1 := currentpicture; clearit; filledsq(diacol2); colsq2 := currentpicture; clearit; filledsq(diacol3); colsq3 := currentpicture; clearit; filledsq(diacol4); colsq4 := currentpicture; clearit; save n; n := 4; save m; m := 6; save gr; picture gr; gr := begingraph(2.4in, 1.8in) setcoords(linear,linear); setrange(0,0,6,28); fill unitsquare xscaled X_.gdim yscaled Y_.gdim withcolor .9white; for y=0 step 4 until 28: grid.lft(format("%f",y), y) withcolor .6white; endfor frame.llft; for x=1 upto 5: otick.bot("",x); endfor save h; %X_.gdim = hhhh * m * (n + 1); hhhh := 0.2; numeric t; path line; t := 0; gdata("data2.d", $, for j=1 upto n: save p; path p; save y; y := scantokens $[j+1]; p := (0,0)--(hhhh,0)--(hhhh,y)--(0,y)--cycle; save sh; sh := t*(n+1)*hhhh+j*hhhh-.5hhhh; gfill p shifted (sh,0) withcolor diacol[j]; gdraw p shifted (sh,0) withpen pencircle scaled .3; endfor augment.line(t,$[2]); glabel($[1],(t+0.5,0)) shifted (0, -2); t := t + 1;); gdraw line shifted (2.5hhhh,0); glabel.bot(btex \textbf{\sf X-Axis Description} etex, OUT); glabel.lft(btex \textbf{\sf Y-Axis Description} etex rotated(90), OUT); endgraph; draw gr; picture lab[]; lab1 = btex \sf\scriptsize Legend1 etex; lab2 = btex \sf\scriptsize Legend2 etex; lab3 = btex \sf\scriptsize Legend3 etex; lab4 = btex \sf\scriptsize Legend4 etex; picture legend; legend := nullpicture; for j=1 upto n: picture legendlab; legendlab := colsq[j]; addto legendlab also lab[j] shifted (lrcorner diasym[j]-llcorner diasym[j] - ((ulcorner lab[j]-llcorner lab[j]) - (ulcorner diasym[j]-llcorner diasym[j]))); pair lsh; lsh := lrcorner legend-llcorner legend; if j > 1: lsh := lsh + (lrcorner diasym[j] - llcorner diasym[j]); fi addto legend also legendlab shifted lsh; endfor pair sh; sh := .5(lrcorner gr + llcorner gr)+(0,-13)-.5(lrcorner legend+llcorner legend); fill bbox legend shifted sh withcolor .9white; draw bbox legend shifted sh; draw legend shifted sh; endfig; end