A Review

2 views
Skip to first unread message

Mojca Miklavec

unread,
Apr 25, 2006, 8:41:15 PM4/25/06
to gnuplot...@googlegroups.com
Hans, finally here's the list that I promised. The most "urgent" part
is part b), ConTeXt (other terminals may wait). Sorry, but I wasn't
able to write much shorter specification.

a) should be done by me anyway and c) are sugars that could come once,
but are not so important at the moment.

Am I still below 1024?

Thanks a lot (is probably not enough),
Mojca
(Hoping that Willi's health is still in good condition.)

What still has to be done:

a) C source inside GNUPLOT (to be done by me):
- adjusting character widths & heights when font size is switched
- [should be easy] implementing palettes & [lower priority - lack of
ideas] 2D patterns
- [not so easy] smooth shading (hacking around in gnuplot source, not
only in context.trm)
- [low priority] implementing drawing of bitmap figures (perhaps
metafun has to be extended for that)
- [higher priority] adding "size" keyword: "set term context size
7in,10cm" (i.e. parsing sizes)
(Inbetween I added font switching & dashed lines, removed BTEX/TEXTEXT
keyword, did some minor steps forward in the direction of
understanding the undocummented color handling in gnuplot.)

b) Adjustments in m-gnuplot.tex (completely independent of (a)):
support for the new ConTeXt terminal

c) (re)write mp-gplot.mp (me) & write support macros in m-gnuplot, so
that different styles & settings will be allowed, most crucial thing
at the moment are point shapes

AD a) not much to be said here.

AD b) I need help and suggestions: where to start? Should ctx tools be
used instead of plain TeX code? Here are some guideline of what could
be done, but most of them are low priority issues (except the support
for ConTeXt terminal):

- [very useful, but not priority] the module has to be able to clean
up the leftovers (texutil --purge[all])
- [saves compile time, but low priority] run gnuplot & compile/convert
the graphics only once per run
- [currently buggy] if someone makes multiple plots with postscript
terminal, some of the graphics aren't converted into PDF yet while the
code keeps running and reports "graphic missing" (it doesn't manage to
be converted to PDF in the meantime)
- terminals might produce more than a single plot; this is not handled
for Postscript, pdf, png, metapost, ... in the current module at the
moment, but in the case of ConTeXt terminal it might make sense to
consider handling multiple plots.

% this makes two plots
\startGNUPLOTscript[trigonometry] % or graphic or whatever
plot sin(x)
plot cos(x)
plot tan(x)
plot asin(x)
plot acos(x)
\stopGNUPLOTscript

and then

\useGNUPLOTgraphic[trigonometry][n=1-3,5] % in the case of postscript
it does \externalfigure[...][page=1] % followed by page=2, page=3,
page=5

\placefigure[here][fig:asin]{$\asin(x)$}{\useGNUPLOTgraphic[trigonometry][n=4]}

Behaviout of different terminals:
* Metapost - creates .mp file with possibly multiple
beginfig(0) .. endfig;
...
begingfig(N) .. endfig;
run metapost + mptopdf
results in multiple PDFs, possibility to include them separately or
all at once (\externalfigure)

* PostScript - creates .ps file with possibly multiple (rotated) pages
do "newpstopdf" conversion, rotate if asked for
possibility to include the pages separately or all at once (\externalfigure)

[the lowest priority]
* LaTeX (pslatex, ...) - creates .tex files with possibly multiple
\begin{figure} .. \end{figure}
write a wrapper to include LaTeX headers, compile with pdfLaTeX, crop,
but don't bother too much about multiple figures unless it's trivial to do so
(i.e. to parse the file and split it at the places between each new figure)
perhaps write some interface to make inclusion if different latex dialects
easier (slightly different headers)
(\externalfigure)

* ConTeXt - creates .tex files that have to be (\input)-ed into a document,
possibly allowing the selection of single graphs or all of them at once
BEWARE: some graphics may come as \startMPpage and some as inline graphics

do with two-way communication with gnuplot in mind (to be
implemented once in the future):
- submit the plots to gnuplot, gnuplot returns all the strings, ConTeXt
typesets them, calculates their dimensions and calls gnuplot again,
this time with string dimensions attached to all the labels
(reason: gnuplot does "strlen()" and usually reserves wrong amount of space
for labels like '$\alpha+\beta$')

Additional explanation for Hans: gnuplot creates a file
"whatevernameisspecified.tex". In the case of "standalone" option it
currently does something like that:

... settings ...
\starttext
\startMPpage
... drawing ...
\stopMPpage
\startMPpage
... drawing ...
\stopMPpage
\startMPpage
... drawing ...
\stopMPpage
\stoptext

(or \startMPcode if "inline" option is chosen instead of "page").

But in most cases this should make a file without "\start|stoptext",
which has to be \input-ed into the document. One of the users (I don't
remember who exactly that was) asked for creating \startuseMPgraphic
instead of \startMPcode, so that the graphic can be called later
(perhaps shrinked, rotated, ...) and that labels can be attached next
to graphics, ... Perhaps I also need to provide the name of the
graphic to gnuplot in that case, otherwise gnuplot doesn't know how to
name it.

I'm attaching a meaningless example that could theoretically be
produced by gnuplot (actual plots are slightly bigger). A question for
Hans & Taco (and if anyone else has more suggestions): How should I
change "startMPcode/startMPpage" in that file, so that the two
graphics will easily be included: either both at the same time or
separately? (I can number the plots easily; naming the graphics is
more problematic since a string with some name should be passed to
gnuplot explicitly in that case - the approach that I don't like
although it's doable.)

Perhaps there should be a new name for that like
\startGNUPLOTgraphic[number] which would do some housekeeping +
MPcode, so that \useGNUPLOTgraphic[name][settings][number(s)] would
eventually recall the proper graphic(s) defined in
\startGNUPLOgraphic; name should be deduced from the name of the
script from which the plot was created. (I imagine [number(s)] to be
something like [1], [1-4,6] or [3-last] or [all] which should be
equivalent to not specifying the last argument at all.)

If someone produces the graphics separately (no additional gnuplot
runs needed; results in a similar file as the attached one), he should
be able to include those graphics in the document easily as well
(either one by one or all of them at the same time).

Sorry for the very fuzzy explanation. Perhaps the others reading this
list should add their opinions and suggestions to it.

AD c) The metapost code that "does everything" is located under
http://renojrl.lrv.uvsq.fr/projects/gpcontext/sample/mp-gplot.mp. I'm
trying to do only "draw_point(number, x, y)" in the gnuplot terminal
itself, the rest is left to metapost code to handle it properly.

Aditya pointed out that points could/should be drawn with metapost
instead of calling them from TeX. I think that both possibilities
should be supported, although it's not yet clear to me how exactly to
set that.

Just an example. Someone can pass an arbitrary number for point type
or line type to gnuplot. The terminal is than responsible for cycling
between colors (if there are 8 line types defined then the color for
"linetype 9" equals the one for "linetype 1"). I temporary hardcoded
those colors in mp-gplot.mp:

numeric gp_num_linetype; gp_num_linetype := 9;
gp_color_lt[-1] := gp_color_foreground;
gp_color_lt[0] := red;
...
gp_color_lt[8] := .5white;

but I would like them to be configurable from the ConTeXt document
(both the number of colors and colors themselves, so that the user
could theoretically also define transparent or cmyk colors if needed).
I would like to create a kind of "styles for gnuplot", so that one
could define a new style in a separate file and the end user could say

\useGNUPLOTstyle[points,dashes][oldfashioned] % or
\useGNUPLOTstyle[all][postscript] % to mimic postscript terminal

The way that the experimental code for points is defined:
\defineconversion[gnuplot][$\bullet$,$\circ$,$\star$,x]
is already an example of such a "configurability" from the original
document, although it's not exactly there yet.

Such configurability includes:
- colors for different linetypes
- dash patterns for different linetypes
- point types (both paths in MP or "whatever" in TeX)
- 2D (fill) patterns (I didn't implement them yet since I have no idea
how to do that and no idea what the default patterns should be;
metapost doesn't support the way they're implemented in postscript,
but this can be circumvented)

Single value parameters (to be passed to gnuplot already):
- (boolean) use_color, use_dash
- scaling for point size, scaling for line widths
- whether it's a whole page or inline graphic
- (some not-so-important ones) ...

(one of the files attached is also available in the darcs repository)

sample3.tex
mp-gplot.mp

Hans Hagen

unread,
Apr 26, 2006, 3:59:24 AM4/26/06
to gnuplot...@googlegroups.com
Mojca Miklavec wrote:

(i assume that we can stick to newtexexec)


> - [very useful, but not priority] the module has to be able to clean
> up the leftovers (texutil --purge[all])
>

ok, what files ...


> - [saves compile time, but low priority] run gnuplot & compile/convert
> the graphics only once per run
>

ok, we need to add the relevant files to the checker that is already in
newtexexec


> - [currently buggy] if someone makes multiple plots with postscript
> terminal, some of the graphics aren't converted into PDF yet while the
> code keeps running and reports "graphic missing" (it doesn't manage to
> be converted to PDF in the meantime)
>

must see that (will you take a laptop t bachotek?)

> - terminals might produce more than a single plot; this is not handled
> for Postscript, pdf, png, metapost, ... in the current module at the
> moment, but in the case of ConTeXt terminal it might make sense to
> consider handling multiple plots.
>
> % this makes two plots
> \startGNUPLOTscript[trigonometry] % or graphic or whatever
> plot sin(x)
> plot cos(x)
> plot tan(x)
> plot asin(x)
> plot acos(x)
> \stopGNUPLOTscript
>
>

should be doable (well, everyting is doable)


> and then
>
> \useGNUPLOTgraphic[trigonometry][n=1-3,5] % in the case of postscript
> it does \externalfigure[...][page=1] % followed by page=2, page=3,
> page=5
>
> \placefigure[here][fig:asin]{$\asin(x)$}{\useGNUPLOTgraphic[trigonometry][n=4]}
>
> Behaviout of different terminals:
> * Metapost - creates .mp file with possibly multiple
> beginfig(0) .. endfig;
> ...
> begingfig(N) .. endfig;
> run metapost + mptopdf
> results in multiple PDFs, possibility to include them separately or
> all at once (\externalfigure)
>

we can make mptopdf produce one pdf (one page per graphic)

actually, metafun has the option:

loadfigure "somename" number 2 ;


> * PostScript - creates .ps file with possibly multiple (rotated) pages
> do "newpstopdf" conversion, rotate if asked for
> possibility to include the pages separately or all at once (\externalfigure)
>
> [the lowest priority]
> * LaTeX (pslatex, ...) - creates .tex files with possibly multiple
> \begin{figure} .. \end{figure}
> write a wrapper to include LaTeX headers, compile with pdfLaTeX, crop,
> but don't bother too much about multiple figures unless it's trivial to do so
> (i.e. to parse the file and split it at the places between each new figure)
> perhaps write some interface to make inclusion if different latex dialects
> easier (slightly different headers)
> (\externalfigure)
>

hm, very low priority indeed


> * ConTeXt - creates .tex files that have to be (\input)-ed into a document,
> possibly allowing the selection of single graphs or all of them at once
> BEWARE: some graphics may come as \startMPpage and some as inline graphics
>
> do with two-way communication with gnuplot in mind (to be
> implemented once in the future):
> - submit the plots to gnuplot, gnuplot returns all the strings, ConTeXt
> typesets them, calculates their dimensions and calls gnuplot again,
> this time with string dimensions attached to all the labels
> (reason: gnuplot does "strlen()" and usually reserves wrong amount of space
> for labels like '$\alpha+\beta$')
>

why not follow a different approach:

- gnuplot writes out coordinates + strings and tex will typeset and
overlay them later; no need to feed back into gp


> Additional explanation for Hans: gnuplot creates a file
> "whatevernameisspecified.tex". In the case of "standalone" option it
> currently does something like that:
>
> ... settings ...
> \starttext
> \startMPpage
> ... drawing ...
> \stopMPpage
> \startMPpage
> ... drawing ...
> \stopMPpage
> \startMPpage
> ... drawing ...
> \stopMPpage
> \stoptext
>
> (or \startMPcode if "inline" option is chosen instead of "page").
>
> But in most cases this should make a file without "\start|stoptext",
> which has to be \input-ed into the document. One of the users (I don't
> remember who exactly that was) asked for creating \startuseMPgraphic
> instead of \startMPcode, so that the graphic can be called later
> (perhaps shrinked, rotated, ...) and that labels can be attached next
> to graphics, ... Perhaps I also need to provide the name of the
> graphic to gnuplot in that case, otherwise gnuplot doesn't know how to
> name it.
>

use or reuse or unique?

maybe add the option to gp-context to specify this


> I'm attaching a meaningless example that could theoretically be
> produced by gnuplot (actual plots are slightly bigger). A question for
> Hans & Taco (and if anyone else has more suggestions): How should I
> change "startMPcode/startMPpage" in that file, so that the two
> graphics will easily be included: either both at the same time or
> separately? (I can number the plots easily; naming the graphics is
> more problematic since a string with some name should be passed to
> gnuplot explicitly in that case - the approach that I don't like
> although it's doable.)
>

etc

let's discuss that later
>
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,
Apr 26, 2006, 6:51:08 PM4/26/06
to gnuplot...@googlegroups.com
On 4/26/06, Hans Hagen <pra...@wxs.nl> wrote:
>
> Mojca Miklavec wrote:
>
> (i assume that we can stick to newtexexec)
> > - [very useful, but not priority] the module has to be able to clean
> > up the leftovers (texutil --purge[all])
> >
> ok, what files ...

.plt (gnuplot scripts), intermediate PostScript, .mp files, ...

> > - [saves compile time, but low priority] run gnuplot & compile/convert
> > the graphics only once per run
> >
> ok, we need to add the relevant files to the checker that is already in
> newtexexec
> > - [currently buggy] if someone makes multiple plots with postscript
> > terminal, some of the graphics aren't converted into PDF yet while the
> > code keeps running and reports "graphic missing" (it doesn't manage to
> > be converted to PDF in the meantime)
> >
> must see that (will you take a laptop t bachotek?)

Sure (unless it's stolen on the train).

Sure, I do that, but Gnuplot reserves space for captions, labels (for
example it produces a smaller graph if the labels on the left are long
or if font size gets bigger). But that's not so important.


> > But in most cases this should make a file without "\start|stoptext",
> > which has to be \input-ed into the document. One of the users (I don't
> > remember who exactly that was) asked for creating \startuseMPgraphic
> > instead of \startMPcode, so that the graphic can be called later
> > (perhaps shrinked, rotated, ...) and that labels can be attached next
> > to graphics, ... Perhaps I also need to provide the name of the
> > graphic to gnuplot in that case, otherwise gnuplot doesn't know how to
> > name it.
> >
> use or reuse or unique?
>
> maybe add the option to gp-context to specify this

"unique" is not needed I think, I'm not sure about the difference &
consequences between "use" and "reuse". (I think that I would prefer
"use", but I'm not sure.)

> > I'm attaching a meaningless example that could theoretically be
> > produced by gnuplot (actual plots are slightly bigger). A question for
> > Hans & Taco (and if anyone else has more suggestions): How should I
> > change "startMPcode/startMPpage" in that file, so that the two
> > graphics will easily be included: either both at the same time or
> > separately? (I can number the plots easily; naming the graphics is
> > more problematic since a string with some name should be passed to
> > gnuplot explicitly in that case - the approach that I don't like
> > although it's doable.)
> >
> etc
>
> let's discuss that later

OK.

Mojca

Reply all
Reply to author
Forward
0 new messages