expansion problems

2 views
Skip to first unread message

Mojca Miklavec

unread,
Jul 23, 2006, 6:32:38 AM7/23/06
to gnuplot...@googlegroups.com
Hello,

now that I managed to get the \startGNUPLOTscript ...
\stopGNUPLOTscript working from within a TeX document & with the
context terminal, I stuggled aganist the same problem that I could
predict already at the beginning.

In the source document I have:

plot [0:3] 2/sqrt(pi)*exp(-x**2) t '$\frac{2}{\sqrt{\pi}}e^{-x^2}$'
with filledcurves x1 lt 3, erf(x)

but in the resulting script file this becomes:

plot [0:3] 2/sqrt(pi)*exp(-x**2) t '$\relax \relax ${{\mathchoice
{\displaystyle 2}{\textstyle 2}{\scriptstyle 2}{\scriptscriptstyle
2}}\over {\mathchoice {\displaystyle \sqrt {\pi }}{\textstyle \sqrt
{\pi }}{\scriptstyle \sqrt {\pi }}{\scriptscriptstyle \sqrt {\pi
}}}}$e^{-x^2}$' with filledcurves x1 lt 3, erf(x);

The same kind of probles happened with \, #, %, ... which have
different meaning in gnuplot and were constantly causing problems.

I would prefer to have something like
\startappendtobuffer[name of that gnuplot file]
...
\stopappendtobuffer
or just anything that doesn't cause problems with expansion but is
rather copied *literally* into the gnuplot script to be processed,
otherwise this might need endless patches and is never really going to
work as expected.

I'll take a look if I can repeat the trick from the \textext "math
patch", but ...

The file that I currently use is for the "module" is
http://renojrl.lrv.uvsq.fr/projects/gpcontext/sample/t-gnuplot.tex

(What really makes me wander: I've sent an email to the mailing list 4
hours ago and it still didn't arrive on the list.)

Mojca

Mojca Miklavec

unread,
Jul 23, 2006, 6:37:54 AM7/23/06
to gnuplot...@googlegroups.com
I'm sorry for reposting this - I don't know what has happend to the
other message sent on the ConTeXt mailing list. If it will be
delivered later (I sent it more than 4 hours ago), plese ignore one of
both copies.


Hello,

the answers to these three questions are most probably one-liners, but
I don't know which ones ;)

1. How can I scale (an already defined) reusableMPgraphic? Simplified
example of what I currently (want to) have:

% how should I change this definition?
\def\usemygraphic[#1][#2]{\reuseMPgraphic{#1}}
\usemygraphic[name][width=.7\textwidth]


2. I have several graphics defined as

\startGNUPLOTgraphic[1][name]
draw fullcircle scaled 3cm withcolor .625red;
\stopGNUPLOTgraphic
\startGNUPLOTgraphic[2][name]
draw fullcircle scaled 3cm withcolor .625green;
\stopGNUPLOTgraphic
\startGNUPLOTgraphic[3][name]
draw fullcircle scaled 3cm withcolor .625blue;
\stopGNUPLOTgraphic

\startGNUPLOTgraphic[1][othername]
fill fullcircle scaled 3cm withcolor .625red;
\stopGNUPLOTgraphic
\startGNUPLOTgraphic[2][othername]
fill fullcircle scaled 3cm withcolor .625green;
\stopGNUPLOTgraphic

and a pretty stupid definition:

\long\def\startGNUPLOTgraphic
{\dodoubleargument\dostartGNUPLOTgraphic}

\long\def\dostartGNUPLOTgraphic[#1][#2]#3\stopGNUPLOTgraphic % [number][name]
{% add to counter to note the nuber of the graphic
% define a new counter for the first time when you use it
\doif{#1}{1}{\doglobal\newcounter\abc}% counter name has to depend on #2
\doglobal\increment\abc % assigning the value #1 to it would also be OK
\startreusableMPgraphic{gpg:#2:#1}#3\stopreusableMPgraphic}

How can I give a better name than \abc to the counter (the name should
depend on #2 in order to be unique)?


3. I would like to change \usemygraphic, so that
\usemygraphic[othername] or \usemygraphic[othername][height=5cm] would
resolve to
\dorecurse{2}{\useMPgraphic{gpg:othername:\recurselevel}}
and \usemygraphic[name][n={1,3},width=8cm] (syntax might be different
if necessary) to
\reuseMPgraphic{gpg:name:1}
\reuseMPgraphic{gpg:name:3}
(with proper scaling if possible).

How should I start?

Thank you a lot for any hints,
Mojca Miklavec

Taco Hoekwater

unread,
Jul 24, 2006, 4:28:03 AM7/24/06
to gnuplot...@googlegroups.com

Mojca Miklavec wrote:
> or just anything that doesn't cause problems with expansion but is
> rather copied *literally* into the gnuplot script to be processed,
> otherwise this might need endless patches and is never really going to
> work as expected.
>

This should do the trick (untested):

\def\dostartGNUPLOTscript#1#2\stopGNUPLOTscript
{\doglobal\increment\GNUPLOTnumber
\letgvalue{gps:n:#1}\GNUPLOTnumber
\setxvalue{gps:d:\GNUPLOTnumber}{\detokenize{#2}}%
\egroup}

Taco

Hans Hagen

unread,
Jul 24, 2006, 5:43:12 AM7/24/06
to gnuplot...@googlegroups.com
this is always a bit tricky; on the one hand you may want to expand
\somestuff

\let\rawtex\detokenize

\edef\xxx{xx \rawtex{xx \zz} xx}

\show\xxx

plot [0:3] 2/sqrt(pi)*exp(-x**2) t '\rawtex{$\frac{2}{\sqrt{\pi}}e^{-x^2}$}'


with filledcurves x1 lt 3, erf(x)

> I'll take a look if I can repeat the trick from the \textext "math
> patch", but ...
>
> The file that I currently use is for the "module" is
> http://renojrl.lrv.uvsq.fr/projects/gpcontext/sample/t-gnuplot.tex
>
> (What really makes me wander: I've sent an email to the mailing list 4
> hours ago and it still didn't arrive on the list.)
>

maybe you math expansion was considere to be spam

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 24, 2006, 6:42:42 AM7/24/06
to gnuplot...@googlegroups.com

Thanks, detokenize helps to get the formula OK (I tried with
normalunexpanded unsuccessfully), but now I have problems with lines
ending with '^M' again (ie: not ending at all).

Wandering:
Why does \externalfigure[nonexistingfigure] work OK (it doesn't
complain, just outputs a gray frame), but
\externalfigure[emptyfile.tex] is fatal?

Thanks a lot,
Mojca

Hans Hagen

unread,
Jul 24, 2006, 7:21:40 AM7/24/06
to gnuplot...@googlegroups.com
you can misuse the obeyMPLines stuff; grep-for-it

Hans

Mojca Miklavec

unread,
Jul 24, 2006, 8:44:05 AM7/24/06
to gnuplot...@googlegroups.com
On 7/24/06, Hans Hagen wrote:
> you can misuse the obeyMPLines stuff; grep-for-it

OK, I'll grep now.

Btw: the MP graphics also/still have lots of ^M in them.

Mojca


PS: this was sent by one of the developers of gnuplot after strong
objections (by almost everyone) to include the context terminal in the
gnuplot version 4.2 (they say that it's too late already):

Well, my voice doesn't weight much in the debate, but I think it's
worth considering the integration of it in 4.2.
Hans [added by me: not Hagen], would you agree to change your mind
there if the code was clean and tested ?

Hans Hagen

unread,
Jul 24, 2006, 9:09:10 AM7/24/06
to gnuplot...@googlegroups.com
how frequently do they release?

anyhow, maybe it helps when you point out that your gnuplot advertisement activities in the tex community depend on it (quality; just stress that the current output is unacceptable)

Mojca Miklavec

unread,
Jul 24, 2006, 11:30:57 AM7/24/06
to gnuplot...@googlegroups.com
> > PS: this was sent by one of the developers of gnuplot after strong
> > objections (by almost everyone) to include the context terminal in the
> > gnuplot version 4.2 (they say that it's too late already):
> >
> > Well, my voice doesn't weight much in the debate, but I think it's
> > worth considering the integration of it in 4.2.
> > Hans [added by me: not Hagen], would you agree to change your mind
> > there if the code was clean and tested ?
> >
> how frequently do they release?

I bet that the next release won't happen before next summer.

> anyhow, maybe it helps when you point out that your gnuplot advertisement activities in the tex community depend on it (quality; just stress that the current output is unacceptable)

Timothée Lecomte sent me a long mail of minor corrections. He's the
only one that supported the inclusion so far. I agree that I'm a bit
slow though.

Before the introduction of \sometxt command I was really afraid to
publish something and now I still have to fix text incusion (\GPtext,
\GPpoint, \GPsetfont).

I will probably also need an option to handle the text inside GPtext
literally (many demo files include _ and $ in labels: _ comes from
file names and $ from specifying which columns to use in the plot).

I'll try to fix the list that Timothée sent me and see if I can
convince the other developers. Some of them have some strange
comments, but most of them are the consequence of not understanding
the details and by being sceptic about two different places (tahat
gnuplot would output something that wouldn't be compatible with the
new version of mp-gnuplot.mp any more; I tried to design it in such a
way to prevent such incompatibilities).

Mojca

Mojca Miklavec

unread,
Jul 26, 2006, 6:04:02 AM7/26/06
to gnuplot...@googlegroups.com
On 7/24/06, Hans Hagen wrote:
>
> you can misuse the obeyMPLines stuff; grep-for-it

I've tried "all" the possible combinations of placing obeyMPlines
somewhere in the code, but I simply cannot get it ...

Thanks for standing me ;),
Mojca

t-gnuplot.tex

Hans Hagen

unread,
Jul 26, 2006, 6:27:32 AM7/26/06
to gnuplot...@googlegroups.com
Mojca Miklavec wrote:
> On 7/24/06, Hans Hagen wrote:
>
>> you can misuse the obeyMPLines stuff; grep-for-it
>>
>
> I've tried "all" the possible combinations of placing obeyMPlines
> somewhere in the code, but I simply cannot get it ...
>
compare:

\long\def\startuniqueMPgraphic
{\blabelgroup
\dodoublegroupempty\dostartuniqueMPgraphic}

\long\def\dostartuniqueMPgraphic
{\obeyMPlines
\dodostartuniqueMPgraphic}

\long\def\dodostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
{\long\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}%
\elabelgroup}

Mojca Miklavec

unread,
Jul 26, 2006, 8:24:37 AM7/26/06
to gnuplot...@googlegroups.com
On 7/26/06, Hans Hagen wrote:
>
> Mojca Miklavec wrote:
> > On 7/24/06, Hans Hagen wrote:
> >
> >> you can misuse the obeyMPLines stuff; grep-for-it
> >>
> >
> > I've tried "all" the possible combinations of placing obeyMPlines
> > somewhere in the code, but I simply cannot get it ...
> >
> compare:
>
> \long\def\startuniqueMPgraphic
> {\blabelgroup
> \dodoublegroupempty\dostartuniqueMPgraphic}
>
> \long\def\dostartuniqueMPgraphic
> {\obeyMPlines
> \dodostartuniqueMPgraphic}
>
> \long\def\dodostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
> {\long\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}%
> \elabelgroup}

OK, I guess that need some fresh air. The fact that
http://pub.mojca.org/gnuplot/sample/abc.tex compiled OK on my computer
at least once tells me that it probably worked at some timepoint in
the past (so I should be able to trace it back in one way or another),
but now I can't make it compile with either version of my old modules.

I'll be back in a week or two.

Mojca

Taco Hoekwater

unread,
Jul 26, 2006, 8:42:41 AM7/26/06
to gnuplot...@googlegroups.com

Mojca Miklavec wrote:
>
> OK, I guess that need some fresh air. The fact that
>

> I'll be back in a week or two.

That is quite a long stretch of fresh air :-)

Taco

Reply all
Reply to author
Forward
0 new messages