ConTeXt의 오류 Mpgraph

ConTeXt의 오류 Mpgraph

ConTeXt 문서에 막대 차트를 넣어야 합니다. 저는 Gentoo GNU/Linux에서 TeX Live 2011의 mkiv를 사용하고 있습니다. Gnuplot을 사용해 보았지만 mpgraph내 필요에 더 잘 맞는다는 것을 알았습니다.

이 TeX 파일을 사용하고 있습니다

\usemodule[graph]
\usemodule[sarith]

\enableregime[utf-8]
\starttext

\startMPcode
beginfig(1)
  draw begingraph(12cm,6cm);
    glabel.lft(btex Eje Y etex, OUT);
    glabel.bot(btex Eje X etex, OUT);
    gdata("data.d",
        $,
        path p;
        augment.p (0,$1);
        augment.p ($2,$1);
        augment p ($2,$1 Sadd "1");
        augment p (0,$1 Sadd "1");
        gdraw p withpen pencircle scaled 2bp withcolor red;
    );
  autogrid(grid.bot,grid.lft) withcolor .85white;
  endgraph;
endfig;
\stopMPcode
\stoptext

그리고 이 데이터 파일

1 4
2 2
3 1
4 2
5 4

최소한의 '작업'예로.

sarith그러나 이상한 일이 일어나고 있습니다. 모듈 에서 연산자를 사용할 수 없습니다 ( mpgraph상자 그리기 모듈에서 사용됨). 나는 얻었다이 출력ConTeXt와 함께. Metapost로 컴파일을 시도했지만 출력 .dvi가 손상되었다는 오류나 경고가 표시되지 않았습니다.

Windows 7에서 TeX Live 2012로도 시도해 보았습니다. 문제 때문에 컴파일할 수 없지만 sarith해당 줄에 주석을 달면 작동합니다. 하지만 젠투 상자에서 동일한 작업을 수행하면 레이블이나 축에 대한 텍스트가 표시되지 않고 아주 작은 사각형만 표시된다는 점만 제외하면 작동합니다. 무슨 일이 일어나고 있는지 이해할 수 없습니다. ConTeXt 위키의 예제도 작동하지 않습니다. 단서? 어떤 도움이라도 매우 감사하겠습니다!

답변1

\usepackage[sarith]다음으로 교체해야합니다.

\startMPinitializations
input sarith;
\stopMPinitializations

sarithConTeXt 모듈이 아니라 메타포스트 패키지이므로 메타포스트 끝에 포함되어야 합니다.

beginfig(1)...endfig게다가 morbusg가 지적했듯이 환경 을 추가할 필요가 없습니다 MPcode. 이 두 가지 변경 사항을 사용하면 다음이 작동합니다.

\usemodule[graph]
\startMPinitializations
input sarith;
\stopMPinitializations

\starttext

\startMPcode
  draw begingraph(12cm,6cm);
    glabel.lft(btex Eje Y etex, OUT);
    glabel.bot(btex Eje X etex, OUT);
    gdata("data.d",
        $,
        path p;
        augment.p (0,$1);
        augment.p ($2,$1);
        augment p ($2,$1 Sadd "1");
        augment p (0,$1 Sadd "1");
        gdraw p withpen pencircle scaled 2bp withcolor red;
    );
  autogrid(grid.bot,grid.lft) withcolor .85white;
  endgraph;
\stopMPcode
\stoptext

답변2

그리드의 숫자 글꼴을 변경하기 위해 자동 설정을 사용하는 대신 그리드 값을 수동으로 설정하면 글꼴이 문서 형식으로 변환된다는 사실을 발견했습니다. 다음은 내 개정판이 포함된 John Handy의 MPGraph 문서의 예입니다.

원래의

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;

~와 함께

draw begingraph(6.5cm,4.5cm);
    setrange(79.5,0, 90.5,80) ;
    glabel.bot(btex Year etex, OUT) shifted(-8pt,-2pt);
    glabel.lft(btex \vbox{% -- \hss fills space horizontally; \strut fixes line space
        \hbox to 5cm {\hss \strut Emissions in thousands of \hss}
        \hbox to 5cm {\hss \strut metric tons (solid line) \hss}
    }
    etex, OUT) shifted(83pt,17pt) rotated 90;
    gdraw "lead.d" withpen pencircle scaled 1pt;
    itick.lft(format("\%2",0),0) withcolor white;
    itick.lft(format("\%2",20),20) withcolor white;
    itick.lft(format("\%2",40),40) withcolor white;
    itick.lft(format("\%2",60),60) withcolor white;
    itick.lft(format("\%2",80),80) withcolor white;
    frame.lft withcolor white ;

    otick.bot(format("\%2",80),80) withcolor white;
    otick.bot(format("\%2",82),82) withcolor white;
    otick.bot(format("\%2",84),84) withcolor white;
    otick.bot(format("\%2",86),86) withcolor white;
    otick.bot(format("\%2",88),88) withcolor white;
    otick.bot(format("\%2",90),90) withcolor white;
endgraph;

이것을 시도해 보세요.

관련 정보