I need to put some bar charts in a ConTeXt document. I'm using mkiv from TeX Live 2011, under Gentoo GNU/Linux. I tried using Gnuplot but I found mpgraph
suits better my needs.
I'm using this TeX file
\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
and this data file
1 4
2 2
3 1
4 2
5 4
as a minimal 'working' example.
However, some strange is happening: I can't use any operator from sarith
module (used in mpgraph
module for drawing boxes). I got this output with ConTeXt. I tried compiling with Metapost, although I got no errors or warnings the output .dvi is corrupted.
I've tried also with TeX Live 2012 under Windows 7. I can't compile there because of the sarith
thing, but when I comment that lines it works. But doing the same thing in my Gentoo box works, excepting that text for labels or axis doesn't appear, just a very little square. I don't understand what is happening, even the example from the ConTeXt wiki doesn't work. Clues? Any help is very appreciated!
beginfig(1)
/endfig
when you run withcontext
,pgfplots
package (which is supposed to work with ConTeXt as well). Metapost provides only a limited plotting capabilities.