From: Alan BRASLAU <alan.braslau@cea.fr>
To: John Kitzmiller <kitz@inradius.net>
Cc: ntg-context@ntg.nl
Subject: Re: m-graph read data and plot
Date: Fri, 7 Aug 2015 12:23:43 +0200 [thread overview]
Message-ID: <20150807122343.0c4d2fba@iram-hb-003386.extra.cea.fr> (raw)
In-Reply-To: <B4C33C31-DD33-48ED-8855-537CDB3C576A@inradius.net>
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 <kitz@inradius.net> wrote:
> On Aug 6, 2015, at 12:59 PM, Hans Hagen <pragma@wxs.nl
> <mailto:pragma@wxs.nl>> 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
> >> <https://en.wikipedia.org/wiki/Box_plot>, either vertical or
> >> horizontal, from data sets, but I am stuck at this early stage.
>
--
Alan Braslau
CEA DSM-IRAMIS-SPEC
CNRS UMR 3680
Orme des Merisiers
91191 Gif-sur-Yvette cedex FRANCE
tel: +33 1 69 08 73 15
fax: +33 1 69 08 87 86
mailto:alan.braslau@cea.fr
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2015-08-07 10:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.931.1438880362.2446.ntg-context@ntg.nl>
2015-08-06 20:48 ` John Kitzmiller
2015-08-07 10:23 ` Alan BRASLAU [this message]
2015-08-07 17:00 ` John Kitzmiller
2015-08-09 12:38 ` Alan BRASLAU
2015-08-13 19:37 ` John Kitzmiller
2015-08-13 19:57 ` Hans Hagen
2015-08-13 20:31 ` Hans Hagen
2015-08-14 2:39 ` Alan BRASLAU
2015-08-21 14:46 ` Hans Hagen
2015-08-06 15:30 John Kitzmiller
2015-08-06 16:25 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150807122343.0c4d2fba@iram-hb-003386.extra.cea.fr \
--to=alan.braslau@cea.fr \
--cc=kitz@inradius.net \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).