m-gnuplot

6 views
Skip to first unread message

Mojca Miklavec

unread,
Jul 21, 2006, 9:01:26 AM7/21/06
to gnuplot...@googlegroups.com
Hello all,

I would really like to finish this gnuplot stuff before the holidays
are finished (or even before) - at least to that phase that it will be
possible to use it directly from tex documents and do the basic setup.
(Butmap images and such may wait a bit, I don't need them right now
anyway.)

I'm fixing some minor things in context.trm right now, but
top-priority is now to set the beginning and end of plots (to enable
later inclusion of graphics and to enable more flexibility in case
that some other command than \startMPcode would be more appropriate in
the future) and to add a higher-level command on top of \sometxt which
would take care of proper font switching, "conversion" to use
different points, ... so that if something more efficient than
\sometxt comes out (just as \sometxt replaced [\]textext) I won't have
problems with backward compatibility.

But I really need help on the ConTeXt side (I do understand C and
ruby, but I still have big problems understanding and writing in TeX).

I have a clear picture of what the module should do, but should I post
the whole specification at once (to see through right away) or should
I do it stepwise?

The most crucial things are the following:

1.

\startGNUPLOT{optional name}
plot sin(x)
\stopGNUPLOT

% or startGNUPLOTscript ? - I would really like to reserve startGNUPLOTgraphic
% for metapost stuff - I hope that not more people than those on this list
% use the module right now

2.

\setupGNUPLOT
[terminal=ps|png|context|...] % context should be the default one

some more (which are not so important):
points=tex|metapost % better name? to be passed to the terminal
% ^ should call "set terminal context pointswithtex | pointswithmetapost"
pointset= % the conversion to use to draw the points
width= % to be passed to the terminal by set terminal size x,y
height= % to be passed to the terminal by set terminal size x,y
fontsize= % to be passed to the terminal

3.

\startGNUPLOTgraphic % I need optional name and number of graphic here
... mp stuff ...
\stopGNUPLOTgraphic
% name is optional because I don't know which name to give to the graphic
% inside gnuplot unless it's explicitely specified in the options

\useGNUPLOTgraphic % optional name and optional number(s)

If no number is specified, include all of the plots (for example if
the resulting PS has 10 pages, include all of them; if the context
terminal produced 5 graphics with
\startGNUPLOTgraphic [1] ... \stopGNUPLOTgraphic
...
\startGNUPLOTgraphic [5] ... \stopGNUPLOTgraphic,
include all of them)

If no name is given, include the last graphic (\startGNUPLOTgrahic)
without name (similar behaviour to buffers with and without names).

I first thought about not supporting multiple graphics, but the fact
is that otherwise one would have to call gnuplot 20 times to get 20
plots. Calling it only once is more efficient.

4.

Inside of \startGNUPLOTgraphic ... \stopGNUPLOTgraphic I would like to
define three additional commands

\GPsetfont[some font] which would just remember the font for later use
in \GPtext,
possibly with empty argument meaning the default document font

\GPtext{whatever text} which would be equivalent to \sometxt, except
that it would authoumatically add \switchtobodyfont[some font]\strut
before "whatever text".

\GPpont{number} which would be equivalent to \sometxt{\someothercommand{number}}
where

\setupGNUPLOT[pointset=point set name]
\defineconversion[point set name][$\bullet$,$\circ$,$\star$,x] % user-defined
\def\someothercommand#1{\convertnumber{point set name}{#1}}
% the one defined in pointset=

(It would be even better if gp_point(number) instead of \GPpoint could
handle that, but I guess that that is not possible [yet].)

That's approximately all for now ;) Well, some things need to be
changed in the current module as well, see
http://wiki.contextgarden.net/Gnuplot_Development#What_has_to_be_fixed_in_m-gnuplot.tex

The most urgent one is to remove "start" from
{\executesystemcommand{start /MIN pgnuplot \GNUPLOTfile.gpd}},
othrwise the cmd windows aren't closed after gnuplot is finished and I
get 20 empty windows open.

Thanks a lot,
Mojca

Hans Hagen

unread,
Jul 21, 2006, 11:34:28 AM7/21/06
to gnuplot...@googlegroups.com
in that case

\startGNUPLOTscript

is better

> 2.
>
> \setupGNUPLOT
> [terminal=ps|png|context|...] % context should be the default one
>
> some more (which are not so important):
> points=tex|metapost % better name? to be passed to the terminal
>

what is the difference? pt vs bp? in that case use unit=bp|pt


> % ^ should call "set terminal context pointswithtex | pointswithmetapost"
> pointset= % the conversion to use to draw the points
> width= % to be passed to the terminal by set terminal size x,y
> height= % to be passed to the terminal by set terminal size x,y
> fontsize= % to be passed to the terminal
>
> 3.
>
> \startGNUPLOTgraphic % I need optional name and number of graphic here
> ... mp stuff ...
> \stopGNUPLOTgraphic
> % name is optional because I don't know which name to give to the graphic
> % inside gnuplot unless it's explicitely specified in the options
>
> \useGNUPLOTgraphic % optional name and optional number(s)
>

what is the difference between a graphic and a script then? or are the
graphics the things generated by gnuplot? is that one visible for the
user? maybe startGNUPLOTresult?


> If no number is specified, include all of the plots (for example if
> the resulting PS has 10 pages, include all of them; if the context
> terminal produced 5 graphics with
> \startGNUPLOTgraphic [1] ... \stopGNUPLOTgraphic
> ...
> \startGNUPLOTgraphic [5] ... \stopGNUPLOTgraphic,
> include all of them)
>

in what sense include ...


> If no name is given, include the last graphic (\startGNUPLOTgrahic)
> without name (similar behaviour to buffers with and without names).
>
> I first thought about not supporting multiple graphics, but the fact
> is that otherwise one would have to call gnuplot 20 times to get 20
> plots. Calling it only once is more efficient.
>

we can be more clever: use the if... (checksum) things that texmfstart
offer + firstrun checking


> 4.
>
> Inside of \startGNUPLOTgraphic ... \stopGNUPLOTgraphic I would like to
> define three additional commands
>
> \GPsetfont[some font] which would just remember the font for later use
> in \GPtext,
> possibly with empty argument meaning the default document font
>

how is that supposed to expand?


> \GPtext{whatever text} which would be equivalent to \sometxt, except
> that it would authoumatically add \switchtobodyfont[some font]\strut
> before "whatever text".
>
> \GPpont{number} which would be equivalent to \sometxt{\someothercommand{number}}
> where
>

pont?


> \setupGNUPLOT[pointset=point set name]
> \defineconversion[point set name][$\bullet$,$\circ$,$\star$,x] % user-defined
> \def\someothercommand#1{\convertnumber{point set name}{#1}}
> % the one defined in pointset=
>
> (It would be even better if gp_point(number) instead of \GPpoint could
> handle that, but I guess that that is not possible [yet].)
>
> That's approximately all for now ;) Well, some things need to be
> changed in the current module as well, see
> http://wiki.contextgarden.net/Gnuplot_Development#What_has_to_be_fixed_in_m-gnuplot.tex
>
> The most urgent one is to remove "start" from
> {\executesystemcommand{start /MIN pgnuplot \GNUPLOTfile.gpd}},
> othrwise the cmd windows aren't closed after gnuplot is finished and I
> get 20 empty windows open.
>

strange since it is supposed to exit (unless an error took place)

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------

Mojca Miklavec

unread,
Jul 21, 2006, 12:00:14 PM7/21/06
to gnuplot...@googlegroups.com
On 7/21/06, Hans Hagen wrote:
:

> > % or startGNUPLOTscript ? - I would really like to reserve startGNUPLOTgraphic
> > % for metapost stuff - I hope that not more people than those on this list
> > % use the module right now
> >
> in that case
>
> \startGNUPLOTscript
>
> is better

OK.

> > 2.
> >
> > \setupGNUPLOT
> > [terminal=ps|png|context|...] % context should be the default one
> >
> > some more (which are not so important):
> > points=tex|metapost % better name? to be passed to the terminal
> >
> what is the difference? pt vs bp? in that case use unit=bp|pt

No. "tex" means "draw points with \defineconversion[whatever
name][x,y,z,$\bullet$, ...]" and "metapost" means drawing (or filling)
circles, squares, stars, diamonds, ... inside metapost. Both should be
configurable though.

> > \startGNUPLOTgraphic % I need optional name and number of graphic here
> > ... mp stuff ...
> > \stopGNUPLOTgraphic
> > % name is optional because I don't know which name to give to the graphic
> > % inside gnuplot unless it's explicitely specified in the options
> >
> > \useGNUPLOTgraphic % optional name and optional number(s)
> >
> what is the difference between a graphic and a script then? or are the
> graphics the things generated by gnuplot? is that one visible for the
> user? maybe startGNUPLOTresult?

Yes, graphics are generated by gnuplot. Currently \startMPcode is used
for that, but this doesn't allow inclusion in a later stage (someone,
I don't remember who, asked if it was possible to use those graphs
separately as \placefigure[]{\useGNUPLOTgraphic[...]})

It depends on what you mean by visible. If someone writes
\startGNUPLOTscript ... \stopGNUPLOTscript then he/she should not
bother about it at all. But if someone take a look at the file
generated by gnuplot it's there. One can run gnuplot separately and
\input that file explicitely from another document.

> > If no number is specified, include all of the plots (for example if
> > the resulting PS has 10 pages, include all of them; if the context
> > terminal produced 5 graphics with
> > \startGNUPLOTgraphic [1] ... \stopGNUPLOTgraphic
> > ...
> > \startGNUPLOTgraphic [5] ... \stopGNUPLOTgraphic,
> > include all of them)
> >
> in what sense include ...

Perhaps "use" is a better word. I might have a script which generated
5 plots and I can either use all the five figures at once (if I don't
specify the number explicitely) or use the figures separately in the
document. (I currently have an option, so that either \startMPcode or
\startMPpage is used to begin gnuplot output. I would like to preserve
the option to create a whole page with a graphic.)

> > If no name is given, include the last graphic (\startGNUPLOTgrahic)
> > without name (similar behaviour to buffers with and without names).
> >
> > I first thought about not supporting multiple graphics, but the fact
> > is that otherwise one would have to call gnuplot 20 times to get 20
> > plots. Calling it only once is more efficient.
> >
> we can be more clever: use the if... (checksum) things that texmfstart
> offer + firstrun checking

Sound OK to me (it's you who's an expert in those things). However
there has to be an option to force running it again (in case that the
data change or document fonts change, md5 of the gnuplot script will
stay the same, but one has to have an option to force running gnuplot
again or recompiling the graphics).

> > 4.
> >
> > Inside of \startGNUPLOTgraphic ... \stopGNUPLOTgraphic I would like to
> > define three additional commands
> >
> > \GPsetfont[some font] which would just remember the font for later use
> > in \GPtext,
> > possibly with empty argument meaning the default document font
> >
> how is that supposed to expand?

I didn't understand the question properly.

> > \GPtext{whatever text} which would be equivalent to \sometxt, except
> > that it would authoumatically add \switchtobodyfont[some font]\strut
> > before "whatever text".
> >
> > \GPpont{number} which would be equivalent to \sometxt{\someothercommand{number}}
> > where
> >
> pont?

"point" of course.

> > \setupGNUPLOT[pointset=point set name]
> > \defineconversion[point set name][$\bullet$,$\circ$,$\star$,x] % user-defined
> > \def\someothercommand#1{\convertnumber{point set name}{#1}}
> > % the one defined in pointset=
> >
> > (It would be even better if gp_point(number) instead of \GPpoint could
> > handle that, but I guess that that is not possible [yet].)
> >
> > That's approximately all for now ;) Well, some things need to be
> > changed in the current module as well, see
> > http://wiki.contextgarden.net/Gnuplot_Development#What_has_to_be_fixed_in_m-gnuplot.tex
> >
> > The most urgent one is to remove "start" from
> > {\executesystemcommand{start /MIN pgnuplot \GNUPLOTfile.gpd}},
> > othrwise the cmd windows aren't closed after gnuplot is finished and I
> > get 20 empty windows open.
> >
> strange since it is supposed to exit (unless an error took place)

Might it be that it's because gnuplot is a .bat file here rather than
an executable?
I had that problem from the very beginning and I never understood why
start is needed.

Thanks a lot,
Mojca

nibua-r

unread,
Jul 21, 2006, 12:07:32 PM7/21/06
to gnuplot-context

Hans Hagen a écrit :

> > \startGNUPLOT{optional name}
> > plot sin(x)
> > \stopGNUPLOT
> >
> > % or startGNUPLOTscript ? - I would really like to reserve startGNUPLOTgraphic
> > % for metapost stuff - I hope that not more people than those on this list
> > % use the module right now
> >
> in that case
>
> \startGNUPLOTscript is better

\startGNUPLOTscript is explicit, sounds good to me

> > \setupGNUPLOT
> > [terminal=ps|png|context|...] % context should be the default one
> >

Do we really need ps or png term support ? At first time, I assume the
answer is yes, but when the context term will be mature ?

> > \startGNUPLOTgraphic % I need optional name and number of graphic here
> > ... mp stuff ...
> > \stopGNUPLOTgraphic
> > % name is optional because I don't know which name to give to the graphic
> > % inside gnuplot unless it's explicitely specified in the options
> >
> > \useGNUPLOTgraphic % optional name and optional number(s)
> >
> what is the difference between a graphic and a script then? or are the
> graphics the things generated by gnuplot? is that one visible for the
> user? maybe startGNUPLOTresult?

I assume:
GNUPLOTgraphic is a kind of shortcut to MPgraphic (it's the environment
for the gnuplot process's result in MP code + MP properties specific to
Gnuplot)

What do we do at the end ?

\setupGNUPLOT[term=context,....]
\startGNUPLOTscript{AGnuplotScript}
plot sin(x)
\stopGNUPLOTscript

\placefigure[here]{My beautiful
$\sin(x)$}{\useGNUPLOTgraphic{AGnuplotScript}}

It can be usefull to define a kind of test first...

Renaud

Hans Hagen

unread,
Jul 21, 2006, 12:09:53 PM7/21/06
to gnuplot...@googlegroups.com
Mojca Miklavec wrote:

> Perhaps "use" is a better word. I might have a script which generated
> 5 plots and I can either use all the five figures at once (if I don't
> specify the number explicitely) or use the figures separately in the
> document. (I currently have an option, so that either \startMPcode or
> \startMPpage is used to begin gnuplot output. I would like to preserve
> the option to create a whole page with a graphic.)
>

so why not generate

\startusableMPgraphic{gnuplot:nr} \stopusableMPgraphic
\startreusableMPgraphic{gnuplot:nr} \stopreusableMPgraphic

> Sound OK to me (it's you who's an expert in those things). However
> there has to be an option to force running it again (in case that the
> data change or document fonts change, md5 of the gnuplot script will
> stay the same, but one has to have an option to force running gnuplot
> again or recompiling the graphics).
>

ok


>
>>> \GPsetfont[some font] which would just remember the font for later use
>>> in \GPtext,
>>> possibly with empty argument meaning the default document font
>>>
>>>
>> how is that supposed to expand?
>>
>
> I didn't understand the question properly.
>

if those \GP commands end up in the mp source ... what code will they
become
>
>>>
>> pont?
>>
>
> "point" of course.
>
not of course, because i was thinking of font


>
> Might it be that it's because gnuplot is a .bat file here rather than
> an executable?
>

maybe


> I had that problem from the very beginning and I never understood why
> start is needed.
>

separate job

Mojca Miklavec

unread,
Jul 21, 2006, 12:16:46 PM7/21/06
to gnuplot...@googlegroups.com
On 7/21/06, nibua-r wrote:
>
> > > \setupGNUPLOT
> > > [terminal=ps|png|context|...] % context should be the default one
> > >
>
> Do we really need ps or png term support ? At first time, I assume the
> answer is yes, but when the context term will be mature ?

The fact is that it's already there, so I don't see any reason to drop
it. PNG might be useful for plotting 1.000.000 points for example
(although I don't know how to compile the terminal properly -
apparently I'm not the only one with such problems, I seem to have too
recent version of compiler which is not supported by gnuplot yet).

PS might be good for ... well, whatever. It was extremely useful
before \sometxt came into existance. It might be faster (more
efficient) and if someone wants some of it's features ... (I hope that
ConTeXt should be able to do all of them - currenlt images and
slightly better font handling is missing, the only remaining issue is
really efficiency).

> > > \startGNUPLOTgraphic % I need optional name and number of graphic here
> > > ... mp stuff ...
> > > \stopGNUPLOTgraphic
> > > % name is optional because I don't know which name to give to the graphic
> > > % inside gnuplot unless it's explicitely specified in the options
> > >
> > > \useGNUPLOTgraphic % optional name and optional number(s)
> > >
> > what is the difference between a graphic and a script then? or are the
> > graphics the things generated by gnuplot? is that one visible for the
> > user? maybe startGNUPLOTresult?
>
> I assume:
> GNUPLOTgraphic is a kind of shortcut to MPgraphic (it's the environment
> for the gnuplot process's result in MP code + MP properties specific to
> Gnuplot)

true.

> What do we do at the end ?

\startGNUPLOTwhatever ... \stopGNUPLOTwhatever of course

> \setupGNUPLOT[term=context,....]
> \startGNUPLOTscript{AGnuplotScript}
> plot sin(x)
> \stopGNUPLOTscript
>
> \placefigure[here]{My beautiful
> $\sin(x)$}{\useGNUPLOTgraphic{AGnuplotScript}}
>
> It can be usefull to define a kind of test first...

Yes, that's true. But it also has to be able to handle

\startGNUPLOTscript{AGnuplotScript}
plot sin(x)
plot cos(x)
plot exp(x)
\stopGNUPLOTscript

\placefigure[here]{My beautiful
$\cos(x)$}{\useGNUPLOTgraphic[n=2]{AGnuplotScript}}

or

\placefigure[here]{My beautiful
$\sin(x), \cos(x), \exp(x)$}{\useGNUPLOTgraphic{AGnuplotScript}}

(I'm only not sure about which braces should be used at what place.)

Thanks,
Mojca

Mojca Miklavec

unread,
Jul 21, 2006, 12:28:00 PM7/21/06
to gnuplot...@googlegroups.com
On 7/21/06, Hans Hagen wrote:
>
> Mojca Miklavec wrote:
>
> > Perhaps "use" is a better word. I might have a script which generated
> > 5 plots and I can either use all the five figures at once (if I don't
> > specify the number explicitely) or use the figures separately in the
> > document. (I currently have an option, so that either \startMPcode or
> > \startMPpage is used to begin gnuplot output. I would like to preserve
> > the option to create a whole page with a graphic.)
> >
> so why not generate
>
> \startusableMPgraphic{gnuplot:nr} \stopusableMPgraphic
> \startreusableMPgraphic{gnuplot:nr} \stopreusableMPgraphic

OK, so that means that I only need something like
\def\startGNUPLOTresult[#1]#2{\startusableMPgraphic{gnuplot:#2:#1}}
?

(I would really like to create a wraper around it.)

> >>> \GPsetfont[some font] which would just remember the font for later use
> >>> in \GPtext,
> >>> possibly with empty argument meaning the default document font
> >>>
> >>>
> >> how is that supposed to expand?
> >>
> >
> > I didn't understand the question properly.
> >
> if those \GP commands end up in the mp source ... what code will they
> become
> >
> >>>
> >> pont?
> >>
> >
> > "point" of course.
> >
> not of course, because i was thinking of font

Sorry. We both seem to misspel a word and I thought that you were
wondering about my misspelling (point -> pont vs. font -> pont).

I didn't think about it. I planned to use the default document font,
but it might indeed make sense to make that font configurable. Font
for labels might need adapted font size as well, but I didn't take to
much care about it yet.

> > Might it be that it's because gnuplot is a .bat file here rather than
> > an executable?
> >
> maybe
> > I had that problem from the very beginning and I never understood why
> > start is needed.
> >
> separate job

Than it was successful ;) I got 20 approximatey windows floating down there ;)

Mojca

Reply all
Reply to author
Forward
0 new messages