如何绘制图表?

如何绘制图表?

我怎样才能用 LaTeX 绘制这个图表?

在此处输入图片描述

答案1

这是元帖子使用盒子库。请随意调整。

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\def\stack#1{\hbox{\vbox{\openup2pt\let\\\cr\halign{&##\hfil\cr#1\crcr}}}}
\mplibtextextlabel{enable}
\begin{mplibcode}
input boxes
beginfig(1);
    boxit.madm("\stack{Multiple attribute\\decision making}");

    boxit.nongen("1. No information");
    boxit.attgen("2. Information on attribute");
    boxit.altgen("3. Information on alternative");

    boxit.att.std("2.1 Standard level");
    boxit.att.ord("2.2 Ordinal");
    boxit.att.car("2.3 Cardinal");
    boxit.att.mar("\stack{2.4 Marginal rate\\of substitution}");

    boxit.alt.pref("3.1 Pairwise preference");
    boxit.alt.prox("3.2 Order of pairwise proximity");

    boxit.non.dom("1.1.1 Dominance");
    boxit.non.maxi("1.1.2 Maximin");
    boxit.non.mini("1.1.3 Minimax");

    boxit.att.std.con("2.1.1 Conjunctive (Satisficing) method");
    boxit.att.std.dis("2.1.2 Disjunctive method");
    boxit.att.ord.lex("2.2.1 Lexicographic method");
    boxit.att.ord.asp("2.2.2 Elimination by aspects");
    boxit.att.ord.per("2.2.3 Permutation method");

    boxit.att.car.lam("2.3.1 Linear assignment method");
    boxit.att.car.saw("2.3.2 Simple additive weighting (SAW) method");
    boxit.att.car.haw("2.3.3 Hierarchical additive weighting");
    boxit.att.car.elc("2.3.4 ELECTRE");
    boxit.att.car.tps("2.3.5 TOPSIS");
    boxit.att.mar.hit("2.4.1 Hierarchical tradeoffs");

    boxit.alt.pref.lin("3.1.1 LINMAP");
    boxit.alt.pref.ism("3.1.2 Interactive SAW method");
    boxit.alt.prox.mds("3.2.1 MDS with ideal point");

    % place all the detailed boxes
    y = 0;
    forsuffixes @=non.dom, non.maxi, non.mini, 
        att.std.con, att.std.dis, 
        att.ord.lex, att.ord.asp, att.ord.per, 
        att.car.lam, att.car.saw, att.car.haw, att.car.elc, att.car.tps, 
        att.mar.hit, 
        alt.pref.lin, alt.pref.ism, alt.prox.mds:
        @.w = (377, -20 incr y);
        drawunboxed(@);
    endfor

    % now work out the middle column positions, relative to the detail
    att.std.w  = (200, ypart 1/2[att.std.con.w, att.std.dis.w]);
    att.ord.w  = (200, ypart 1/2[att.ord.lex.w, att.ord.per.w]);
    att.car.w  = (200, ypart 1/2[att.car.lam.w, att.car.tps.w]);
    att.mar.w  = (200, ypart att.mar.hit.w);
    alt.pref.w = (200, ypart 1/2[alt.pref.lin.w, alt.pref.ism.w]); 
    alt.prox.w = (200, ypart alt.prox.mds.w); 

    % and the top level relative to the middle
    nongen.w = (34, ypart non.maxi.c);
    attgen.w = (34, ypart 1/2[att.std.w, att.mar.w]);
    altgen.w = (34, ypart 1/2[alt.pref.w, alt.prox.w]);

    % and the root
    madm.e = attgen.w shifted 42 left;

    % draw all the "boxes" but without the lines round them...
    drawunboxed(madm, nongen, attgen, altgen, att.std, att.ord, att.car, att.mar, alt.pref, alt.prox);

    % now do three sets of lines in different colours
    drawoptions(withcolor 2/3 red);

    draw madm.c { right } .. tension 1.2 .. { right } nongen.w cutbefore bpath madm;

    forsuffixes @ = non.dom, non.maxi, non.mini:
        draw nongen.e -- (340, ypart nongen.e) {right} .. {right} @.w;
    endfor

    drawoptions(withcolor 2/3 blue);

    draw madm.c { right } .. tension 1.2 .. { right } attgen.w cutbefore bpath madm;

    forsuffixes @ = att.std, att.ord, att.car, att.mar:
        draw attgen.c { right } .. tension 1.2 .. { right } @.w cutbefore bpath attgen;
    endfor

    forsuffixes @ = att.std.con, att.std.dis:
        draw att.std.e -- (340, ypart att.std.e) {right} .. {right} @.w;
    endfor

    forsuffixes @ = att.ord.lex, att.ord.asp, att.ord.per:
        draw att.ord.e -- (340, ypart att.ord.e) {right} .. {right} @.w;
    endfor

    forsuffixes @ = att.car.lam, att.car.saw, att.car.haw, att.car.elc, att.car.tps:
        draw att.car.e -- (340, ypart att.car.e) {right} .. {right} @.w;
    endfor

    draw att.mar.e -- att.mar.hit.w;

    drawoptions(withcolor 2/3 green);
    draw madm.c { right } .. tension 1.2 .. { right } altgen.w cutbefore bpath madm;

    forsuffixes @ = alt.pref, alt.prox:
        draw altgen.c { right } .. tension 1.2 .. { right } @.w cutbefore bpath altgen;
    endfor

    forsuffixes @ = alt.pref.lin, alt.pref.ism:
        draw alt.pref.e -- (340, ypart alt.pref.e) {right} .. {right} @.w;
    endfor

    draw alt.prox.e -- alt.prox.mds.w;

    drawoptions();

endfig;
\end{mplibcode}
\end{document}

这是用完成的,luamblib所以你需要用编译它lualatex(或者想办法让它适应良好生产规范+ pdflatex,或者普通的 Metapost)。

相关内容