input graph;
prologues := 3;
outputformat := "svg";
outputtemplate := "VIZ-11-004.svg";
color Blue, Teal, Orange, Wash, Missing;
Blue := (0, 84 / 255, 159 / 255);
Teal := (0, 177 / 255, 183 / 255);
Orange := (246 / 255, 168 / 255, 0);
Wash := (232 / 255, 241 / 255, 250 / 255);
Missing := (236 / 255, 236 / 255, 237 / 255);
vardef P(expr x, y) =
    (55 + 345 * (x - (0)) / (75), 45 + 175 * (y - (0.5)) / (4.0))
enddef;
def rect(expr x, y, xx, yy, col) =
    fill P(x, y)--P(xx, y)--P(xx, yy)--P(x, yy)--cycle withcolor col;
enddef;
beginfig(1);
    fill unitsquare xscaled 420 yscaled 280 withcolor white;
    label.llft("VIZ-11-004" infont "cmr8", (414, 272));
    label.rt(btex Colour: survival 0-100\%; circle area: n etex scaled .65, (55, 246));
    fill unitsquare xscaled 6 yscaled 6 shifted (55, 231) withcolor 0.025[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (61, 231) withcolor 0.075[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (67, 231) withcolor 0.125[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (73, 231) withcolor 0.175[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (79, 231) withcolor 0.225[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (85, 231) withcolor 0.275[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (91, 231) withcolor 0.325[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (97, 231) withcolor 0.375[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (103, 231) withcolor 0.425[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (109, 231) withcolor 0.475[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (115, 231) withcolor 0.525[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (121, 231) withcolor 0.575[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (127, 231) withcolor 0.625[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (133, 231) withcolor 0.675[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (139, 231) withcolor 0.725[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (145, 231) withcolor 0.775[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (151, 231) withcolor 0.825[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (157, 231) withcolor 0.875[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (163, 231) withcolor 0.925[Wash, Blue];
    fill unitsquare xscaled 6 yscaled 6 shifted (169, 231) withcolor 0.975[Wash, Blue];
    label.bot(btex 0 etex scaled .6, (55, 230));
    label.bot(btex 50 etex scaled .6, (115, 230));
    label.bot(btex 100\% etex scaled .6, (175, 230));
    fill fullcircle scaled 3.975732839729454 shifted (280, 235) withcolor Blue;
    label.bot(btex n=10 etex scaled .6, (280, 227));
    fill fullcircle scaled 8.890008890013334 shifted (325, 235) withcolor Blue;
    label.bot(btex n=50 etex scaled .6, (325, 227));
    fill fullcircle scaled 12.572371141874243 shifted (370, 235) withcolor Blue;
    label.bot(btex n=100 etex scaled .6, (370, 227));
    draw P(0, 4.5)--P(0, 0.5)--P(75, 0.5) withcolor .4white;
    label.bot(btex 0 etex scaled .7, P(0, 0.5));
    label.bot(btex 15 etex scaled .7, P(15, 0.5));
    label.bot(btex 30 etex scaled .7, P(30, 0.5));
    label.bot(btex 45 etex scaled .7, P(45, 0.5));
    label.bot(btex 60 etex scaled .7, P(60, 0.5));
    label.bot(btex 75 etex scaled .7, P(75, 0.5));
    label.lft(btex Crew etex scaled .7, P(0, 1));
    label.lft(btex 3rd etex scaled .7, P(0, 2));
    label.lft(btex 2nd etex scaled .7, P(0, 3));
    label.lft(btex 1st etex scaled .7, P(0, 4));
    label(btex Age band (years) etex scaled .8, (227.5, 13));
    label(btex Group etex scaled .8 rotated 90, (13, 132));
% BEGIN EXAMPLE
    numeric n, v[][];
    n := 0;
    gdata("data/cells.tsv", c,
        n := n + 1;
        for j = 1 upto 6:
            v[n][j] := scantokens c[j];
        endfor
    );
    for k = 1 upto n:
        if v[k][4] > 0:
            fill fullcircle scaled v[k][6] shifted P(v[k][1], v[k][2])
                withcolor (v[k][3] / 100)[Wash, Blue];
        fi
    endfor
% END EXAMPLE
    setbounds currentpicture to unitsquare xscaled 420 yscaled 280;
endfig;
end.
