Thank you Alan. setrange is the key I had not tried and I will be more careful with (2). This may not be the proper way to ask, but it is related to the topic: how to get Hobby’s Figure 9 from the mpgraph manual to work using m-graph? http://ctan.org/tex-archive/systems/doc/metapost/source-manual Thanks again, John On Aug 7, 2015, at 6:23 AM, Alan BRASLAU wrote: > > You have two problems: > > 1) gdraw (4,1)--(7,1); > has a unique ordinate, so graph will fail in this case if you do not > explicitly set the range. > > 2) You have to take care with your choice of loop variables in MP not > to run into conflicts those eventually used in macros. Also, as Hans > indicated, you do need to declare that a is an array, as in > numeric a[]; > > Here is a MWE > > \enabletrackers[metapost.showlog] > \usemodule[graph] > \startMPpage[instance=graph,offset=3mm] > draw begingraph(5cm,5cm); > numeric a[]; > gdata("data.d", v, > for j=1 upto 3: > a[j]:=scantokens v[j]; > endfor ; > ); > > setrange (whatever,0,whatever,2); > gdraw (a2,a1)--(a3,a1); > endgraph; > \stopMPpage > > > Alan > > > On Thu, 6 Aug 2015 16:48:51 -0400 > John Kitzmiller > wrote: > >> On Aug 6, 2015, at 12:59 PM, Hans Hagen >> >> wrote: >>> >>> On 8/6/2015 5:30 PM, John Kitzmiller wrote: >>>> Given a file, data.d, containing 1 4 7 >>>> >>>> I expected the following code to draw a line from (4,1) to (7,1)… >>>> >>>> >>>> \enabletrackers[metapost.showlog] >>>> \usemodule[m-graph] >>>> \startMPpage[instance=graph,offset=3mm] >>>> draw begingraph(5cm,5cm); >>>> gdata("data.d", v, >>>> for n = 1 upto 3: >>>> a[n] = scantokens v[n]; >>>> endfor; >>>> >>>> show a1; show a2; show a3; % numeric >>>> show v1; show v2; show v3; % string >>>> gdraw (a2,a1)—(a3,a1); % same problem in or out of data group >>>> ); >>>> endgraph; >>>> \stopMPpage >>>> >>>> …the show lines return what I expected, but then come the >>>> complaints: >>>> >>>> ! Inconsistent equation (off by 0.90000000000000002)… >>>>>> (0,0,1,0,0,yypart S) >>>> ! Transform components aren't all known… >>>> >>> >>>> a[n] = scantokens v[n]; >>> >>> is a defined? >> >> Thank you Hans. Do you mean numeric a[n]? It was not explicitly >> declared; I did not think it needed to be—the show commands write >> what I expect to the log—anyway, declaring a did not help. >> >>> >>> also, use >>> >>> a[n] := scantokens v[n] ; >> >> Done. Still the same error messages and no pdf. >> >>> >>> >>> >>>> My goal is to draw multiple box plots >>>> https://en.wikipedia.org/wiki/Box_plot >>>> >, either vertical or >>>> horizontal, from data sets, but I am stuck at this early stage. >> >