input graph;
prologues := 3;
outputformat := "svg";
outputtemplate := "VIZ-02-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.5)) / (4.0), 45 + 175 * (y - (0)) / (1000))
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-02-004" infont "cmr8", (414, 272));
    label.rt(btex Survived (blue) / did not survive (orange) etex scaled .65, (55,
        246));
    draw P(0.5, 1000)--P(0.5, 0)--P(4.5, 0) withcolor .4white;
    label.bot(btex 1st etex scaled .7, P(1, 0));
    label.bot(btex 2nd etex scaled .7, P(2, 0));
    label.bot(btex 3rd etex scaled .7, P(3, 0));
    label.bot(btex Crew etex scaled .7, P(4, 0));
    label.lft(btex 0 etex scaled .7, P(0.5, 0));
    label.lft(btex 200 etex scaled .7, P(0.5, 200));
    label.lft(btex 400 etex scaled .7, P(0.5, 400));
    label.lft(btex 600 etex scaled .7, P(0.5, 600));
    label.lft(btex 800 etex scaled .7, P(0.5, 800));
    label.lft(btex 1000 etex scaled .7, P(0.5, 1000));
    label(btex Passenger class / crew etex scaled .8, (227.5, 13));
    label(btex People etex scaled .8 rotated 90, (13, 132));
% BEGIN EXAMPLE
    numeric n, v[][];
    n := 0;
    gdata("data/classes.tsv", c,
        n := n + 1;
        for j = 1 upto 12:
            v[n][j] := scantokens c[j];
        endfor
    );
    for k = 1 upto n:
        rect(v[k][1] - .325, 0, v[k][1] + .325, v[k][2], Orange);
        rect(v[k][1] - .325, 0, v[k][1] + .325, v[k][3], Blue);
    endfor
% END EXAMPLE
    setbounds currentpicture to unitsquare xscaled 420 yscaled 280;
endfig;
end.
