Fwd: context terminal for gnuplot

6 views
Skip to first unread message

Mojca Miklavec

unread,
Mar 13, 2006, 9:47:26 PM3/13/06
to gnuplot...@googlegroups.com, Hans Hagen
This is not annoying mail in any case. I realized there are problems
with btex ... etex, but I have no idea how to deal with them. Unless
Hans or Taco help me out here, I have no idea what to do.

I would also need that terminal desperately, but just after I
announced the preliminary version of the terminal being out and after
I already successfully compiled the demo, I wasn't able to use the
context terminal any more for my reports, so I was forced to use the
postscript terminal again.

Two problems I had:
1. the first one is "described" in http://pub.mojca.org/gnuplot/problems/
2. [new]texexec runs the text inside textext() or inside btex ... etex
with TeX format preloaded (insted of ConTeXt format)

I had even more problems with textext, so I skipped proper handling of
that part for a while. I also miss (have to add) handling of font
names, but I have to figure out how exactly to do that first. If btex
... etex is run as plain TeX, there's not much I can do about it
anyway.

There should be no difference in "standalone" and "included" version
of gnuplot graphic ... except if ... handling of "btex ... etex" is
(unintentionally) different for the main document and for included
(\input) documents.

Mojca


---------- Forwarded message ----------
From: Renaud AUBIN <au...@nibua-r.org>
Date: Mar 13, 2006 3:37 PM

Hello Mojca,

I'm sorry to send you this kind of annoying mail...

I'm trying to use and understand your context terminal of gnuplot and
I need your pov on this problems:
- not a problem: context terminal works well for me, considering the
function or data plottings, (without gp_put_text)
- main problem: I get (with gp_put_text)

! Unable to make mpx file.
l.82 if string str = true : pict := btex
x etex;
The two files given above are one of your source files
and an auxiliary file I need to read to find out what your
btex..etex blocks mean. If you don't know why I had trouble,
try running it manually through MPto -tex, TeX, and DVItoMP.

... In fact, I experienced problems with btex ... etex... I don't
understand why because gp_the_text seems correct... I suppose a
configuration problems because if I use a standalone graphic with draw
btex ... etex, it works...

I have tried a lot of things but I've always the same kind of
problems (btex...etex)

Argh... It seems that the solution is trivial but I can't put the
finger on it !!! With this problem, it's hard to me to concentrate on
other needs or improvments...

Any idea ?

I really need this terminal for my 2D plots...

Cheers,

Mojca Miklavec

unread,
Mar 13, 2006, 10:03:05 PM3/13/06
to gnuplot...@googlegroups.com
> There should be no difference in "standalone" and "included" version
> of gnuplot graphic ... except if ... handling of "btex ... etex" is
> (unintentionally) different for the main document and for included
> (\input) documents.

A couple of minutes later I've read Taco's post on the metapost
mailing list: mpto used for typesetting the content of btex ... etex
cannot read parent files. Well, it makes sense and I already noticed
that "mpto.exe" is relatively old & stupid.

I'll play a bit more with the samples. My feeling is that with all the
machinery already present in texexec, rewriting "mpto" in ruby (in the
same way as it was done with kpsea) would be a quicker & cleaner way
than any other way of hacking the samples, but since I don't know
enough about any of the programs, I might be totally wrong.

But at least I have a feeling of what might have gone wrong. Renaud,
thanks for the remark about standalone graphics. I would never have
thought about the difference in handling master files & included
files. That might answer quite some questions.

Mojca

Hans Hagen

unread,
Mar 14, 2006, 1:17:00 PM3/14/06
to gnuplot...@googlegroups.com
use textext instead of btex ... etex and texexec will take care of it

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
-----------------------------------------------------------------

Hans Hagen

unread,
Mar 14, 2006, 1:25:52 PM3/14/06
to Mojca Miklavec, gnuplot...@googlegroups.com
Mojca Miklavec wrote:
> This is not annoying mail in any case. I realized there are problems
> with btex ... etex, but I have no idea how to deal with them. Unless
> Hans or Taco help me out here, I have no idea what to do.
>
> I would also need that terminal desperately, but just after I
> announced the preliminary version of the terminal being out and after
> I already successfully compiled the demo, I wasn't able to use the
> context terminal any more for my reports, so I was forced to use the
> postscript terminal again.
>
> Two problems I had:
> 1. the first one is "described" in http://pub.mojca.org/gnuplot/problems/
>

\starttext
\startMPcode
vardef gp_the_text(expr align, str) =
save pict; picture pict;
if string str :
%pict := textext(str);


pict := btex x etex;

elseif picture str :
pict := str;
fi;

pict
enddef;

def gp_put_text(expr pos, angle, str) =
draw gp_the_text(align, str) rotated angle shifted pos;
enddef;

a:=5in/120.00; b:=5in/120.00;
draw fullcircle scaled 3cm;
gp_put_text((0,0), 0, btex -1 etex);
gp_put_text((.5cm,.5cm), 0, "-0.8");

\stopMPcode
\stoptext

the mp utilities parse the file and btex ... etex is replaced inline by
a reference to a picture and never ends up in gp_the_text

textext is more clever and writes to an external file which is processed
in between

(if you want to process just the mp graphic run texexec --mptex
whatever.mp)

> 2. [new]texexec runs the text inside textext() or inside btex ... etex
> with TeX format preloaded (insted of ConTeXt format)
>

hm.


> I had even more problems with textext, so I skipped proper handling of
> that part for a while. I also miss (have to add) handling of font
> names, but I have to figure out how exactly to do that first. If btex
> ... etex is run as plain TeX, there's not much I can do about it
> anyway.
>

foxus on textext


> There should be no difference in "standalone" and "included" version
> of gnuplot graphic ... except if ... handling of "btex ... etex" is
> (unintentionally) different for the main document and for included
> (\input) documents.
>

nibua-r

unread,
Mar 14, 2006, 2:23:58 PM3/14/06
to gnuplot-context

Hi,

I have tested the macros provided by Hans on a sample. It works fine
(without "align" and color mngt), but there is another problem.
Considering a path defined from a large number of pairs (i.e. the
function to plot) and generated by the context terminal of gnuplot, I
got "unknown" for each text... If I comment out this path definition
and the corresponding gp_draw, it's ok for the text but obviously, I
don't have the function...

Cheers,

PS: I could maybe setup a darcs repository for the (context term +
sample) code, your opinion ?

Renaud

nibua-r

unread,
Mar 14, 2006, 2:40:41 PM3/14/06
to gnuplot-context
I must add to this that gp_the_text and gp_put_text is within
(start,stop)MPcode. If I put these definitions in MPinclusions, I
obtain "unknown" as text.

nibua-r

unread,
Mar 14, 2006, 3:30:11 PM3/14/06
to gnuplot-context
For path related problem:
- <= 57 pairs work
- > 57 pairs don't work

nibua-r

unread,
Mar 14, 2006, 5:43:30 PM3/14/06
to gnuplot-context

A suggestion:
IMO, it could be nice if the context terminal returns directly
\startuseMPgraphic{dummy} ... \stopuseMPgraphic. For this purpose,
changing {input | standalone} to {code | graphic | standalone} or
{input | figure | standalone} and adding a label option (label dummy)
will maybe be a good idea. I can probably implement that... Feel free
to give your opinion or advice !

Hans Hagen

unread,
Mar 15, 2006, 3:28:52 AM3/15/06
to gnuplot...@googlegroups.com
also when you say \forceMPTEXgraphictrue ?

Hans Hagen

unread,
Mar 15, 2006, 3:29:51 AM3/15/06
to gnuplot...@googlegroups.com
it indeed makes sense to have a place to test samples

nibua-r

unread,
Mar 15, 2006, 8:37:29 AM3/15/06
to gnuplot-context

OK, text macros included in MPinclusions work with
\forceMPTEXgraphictrue

Thank you Hans

Renaud

nibua-r

unread,
Mar 15, 2006, 8:39:43 AM3/15/06
to gnuplot-context

What do you mean by "a place to test samples" ? Online, offline
"testbed" document or ... ?

Renaud

Taco Hoekwater

unread,
Mar 15, 2006, 12:44:18 PM3/15/06
to gnuplot...@googlegroups.com

some kind of line length overflow perhaps?

Taco

nibua-r

unread,
Mar 15, 2006, 1:19:10 PM3/15/06
to gnuplot-context
I have checked and you're right...

Taco Hoekwater

unread,
Mar 17, 2006, 9:13:12 AM3/17/06
to gnuplot...@googlegroups.com

nibua-r wrote:
> I have checked and you're right...

The actual problem was that the lines in the XXX-mpgraph.mp
became too long. As a result of that, "mpto" refuses to run.

The (rather ugly) fix I give below makes sure that the lines
do not become overly long, by redefining the core macro
\flushMPgraphicline. It seems to work ok, over here.

Cheers, Taco

%D \macros{flushMPgraphicline}
%D this is redefined the core macro. the two additional
%D \type{\doifinstringelse} tests are new.

\def\flushMPgraphicline#1#2;%
{\ifx #1\relax \else
\doifinstringelse{..}{#1#2}% NEW
{\breakMPgraphiclinedotted{#1#2}}
{\doifinstringelse{--}{#1#2}
{\breakMPgraphiclinedashed{#1#2}}
{\immediate\write\MPwrite {#1#2;}}}%
\expandafter \flushMPgraphicline
\fi }

%D the following 2 sets of macros differ only in their
%D terminal condition

\def\breakMPgraphiclinedotted#1%
{{\def\tempa{}\dobreakMPgraphiclinedotted#1..\relax..}}

\def\dobreakMPgraphiclinedotted#1..%
{\ifx#1\relax
\immediate\write\MPwrite {\tempa;}%
\else
\ifx\tempa\empty \else
\immediate\write\MPwrite {\tempa..}%
\fi
\def\tempa{#1}%
\expandafter \dobreakMPgraphiclinedotted
\fi }

\def\breakMPgraphiclinedashed#1%
{{\def\tempa{}\dobreakMPgraphiclinedashed#1--\relax--}}

\def\dobreakMPgraphiclinedashed#1--%
{\ifx#1\relax
\immediate\write\MPwrite {\tempa;}%
\else
\ifx\tempa\empty \else
\immediate\write\MPwrite {\tempa--}%
\fi
\def\tempa{#1}%
\expandafter \dobreakMPgraphiclinedashed
\fi }

%D End

Mojca Miklavec

unread,
Mar 17, 2006, 9:25:39 AM3/17/06
to gnuplot...@googlegroups.com
This btex ... etex / textext will drive me crazy.

With textext() I don't have problems with labels processed with plain
tex instead of context format any more, but I only get "unknown" as
labels.

> > I must add to this that gp_the_text and gp_put_text is within
> > (start,stop)MPcode. If I put these definitions in MPinclusions, I
> > obtain "unknown" as text.
> >

> also when you say \forceMPTEXgraphictrue ?

Yes, also after that.

I tried a stupid experiment which I don't understand any more. With
miktex I only get "unknown". With stand-alone I get "proper" labels
(well, I still get junk for strings like textext("č\zcaron"): I get
".269.zcaron"), but as soon as I replace "texexec.pl" with
"newtexexec.rb" in texexec.bat, I get "unknown" labels again. I'm
totally confused and don't have the slightest idea about what's going
on.

I was already thinking about that. (\startuseMPgraphic), which could
then be used approximately as
\placefigure
{some description}
{\useMPgraphic ...}

The problem is that one can have more than one plot (ie. more than a
single graphic), so what would you do in such cases (same question for
the existing terminals which currently include the first graphic
only)? I was thinking about something similar to
\useGNUPLOTgraphic[number=3]{name}. I know that \startMPcode is not
the best possible choice, but I have very little or no knowledge about
hacking low-level ConTeXt. Changing this particular detail in gnuplot
terminal is relatively simple once the proper support on the ConTeXt
side is written.

So: any suggestions about what to do with multiple plots? My first
idea was approximately: if you want to do complex things with
graphics, draw them separately. Adding labels is surely more advanced
way of doing it.

Perhaps \startGNUPLOTscript{a very nice plot} should invoke
set terminal context label 'a very nice plot'
and then
\startuseMPgraphic{a very nice plot:1} ... \stopuseMPgraphic
\startuseMPgraphic{a very nice plot:2} ... \stopuseMPgraphic
\startuseMPgraphic{a very nice plot:3} ... \stopuseMPgraphic
or some similar variant. Yes, I would ask once more: suggestions?

What does that mean? I didn't have any problems till now & the
terminal source can most probably be fixed; what exactly should be
changed (can you please send an example or describe the problem)?

About the repository: I think it would be very helpful to set up a
repository, I only didn't get time yet to set up one.

Mojca

Mojca Miklavec

unread,
Mar 17, 2006, 9:32:53 AM3/17/06
to gnuplot...@googlegroups.com
On 3/17/06, Taco Hoekwater wrote:
> nibua-r wrote:
> > I have checked and you're right...
>
> The actual problem was that the lines in the XXX-mpgraph.mp
> became too long. As a result of that, "mpto" refuses to run.
>
> The (rather ugly) fix I give below makes sure that the lines
> do not become overly long, by redefining the core macro
> \flushMPgraphicline. It seems to work ok, over here.

Didn't try the patch out yet, but I noticed that "problem" already
(although it didn't know if it was actually a problem or not). I
splitted the paths in multiple lines, but ConTeXt joined them again.

Thank you Taco.

Mojca

nibua-r

unread,
Mar 17, 2006, 9:47:25 AM3/17/06
to gnuplot-context
The darcs repository is ready but could prepare an initial revision ?

Taco Hoekwater

unread,
Mar 17, 2006, 9:50:16 AM3/17/06
to gnuplot...@googlegroups.com

Mojca Miklavec wrote:
> This btex ... etex / textext will drive me crazy.
>
> With textext() I don't have problems with labels processed with plain
> tex instead of context format any more, but I only get "unknown" as
> labels.

Most of that label stuff is the same problem, rehashed. If metapost
is run directly, it will work, because the lines are short (as created
by gnuplot). If the plot is passed through context, it fails to create
the proper labels, because context makes very long lines, and those
long lines make metapost's "makempx" fail.

None of this is caused by the use of textext(), and the metapost run
will not fail, it just creates incorrect ("unknown") labels in an
otherwise perfectly fine graphic.

Cheers, taco

Mojca Miklavec

unread,
Mar 17, 2006, 10:22:00 AM3/17/06
to gnuplot...@googlegroups.com
On 3/17/06, Taco Hoekwater wrote:
>

The lines in my example are short enough. I noticed an interesting
syndrome though. With texexec.pl it kind-of-works (problems with utf-8
& some commands like \zcaron & such, but that's not so important at
the moment), while newtexexec.rb produces "unknown"s.

Mojca

To Renaud: I didn't understand your question. Do you need the first
files to fill the repository?

Taco Hoekwater

unread,
Mar 17, 2006, 10:31:03 AM3/17/06
to gnuplot...@googlegroups.com

Mojca Miklavec wrote:
>
> The lines in my example are short enough. I noticed an interesting
> syndrome though. With texexec.pl it kind-of-works (problems with utf-8
> & some commands like \zcaron & such, but that's not so important at
> the moment), while newtexexec.rb produces "unknown"s.

Verified. But I'm not versed enough in ruby to know what is wrong.

Taco

Mojca Miklavec

unread,
Mar 17, 2006, 10:34:03 AM3/17/06
to gnuplot...@googlegroups.com
Can anyone please try to run the following minimal example with both
newtexexec.rb & texexec.pl (running texmfstart [new]texexec only
doesn't help; texexec has to resolve to either one of them):

\starttext
\startMPcode
draw textext("abc");
\stopMPcode
\stoptext

On my computer only the old texexec produces the correct output (tried
on two distributions).

I also suspec something strange:
texmfstart [whatevertexexec] --batch --output=dvips
--mpformat=metafun --mptex --nomp --once filename-mpgraph

In newtexexec.rb I didn't find most of the switches mentioned here.
Where exactly are they defined?

Thanks,
Mojca

nibua-r

unread,
Mar 17, 2006, 10:38:33 AM3/17/06
to gnuplot-context
Yes,

Is the http://pub.mojca.org/gnuplot/trm/context.trm up to date (I use
this one here)

For the moment I propose:
./gpcontext/
trm/context.trm
sample/sample.gp or .plt as you want...
sample/document.tex -> (with \forceMPTEXgraphictrue and Taco's
fix)
sample/gp-localdef.tex

nibua-r

unread,
Mar 17, 2006, 10:42:55 AM3/17/06
to gnuplot-context
To all: Check first http://darcs.net/ if you're agree to use it !
(under linux, it's simple to use but dunno how it is with windows)

Cheers

Taco Hoekwater

unread,
Mar 17, 2006, 10:50:17 AM3/17/06
to gnuplot...@googlegroups.com

Mojca Miklavec wrote:
> Can anyone please try to run the following minimal example with both
> newtexexec.rb & texexec.pl (running texmfstart [new]texexec only
> doesn't help; texexec has to resolve to either one of them):
>
> \starttext
> \startMPcode
> draw textext("abc");
> \stopMPcode
> \stoptext
>
> On my computer only the old texexec produces the correct output (tried
> on two distributions).

Same here :(

> I also suspec something strange:
> texmfstart [whatevertexexec] --batch --output=dvips
> --mpformat=metafun --mptex --nomp --once filename-mpgraph
>
> In newtexexec.rb I didn't find most of the switches mentioned here.
> Where exactly are they defined?

most options are in scripts/context/ruby/base/tex.rb:

--batch: texmfstart.rb
--output: base/tex.rb
--mpformat : not implemented
--mptex: newtexexec.rb
--nomp: base/tex.rb
--once: base/tex.rb

Cheers, Taco

nibua-r

unread,
Mar 17, 2006, 11:02:49 AM3/17/06
to gnuplot-context
texexec test & texmfstart texexec test give same results... what do you
mean by running texmfstart [new]texexec only doesn't help; texexec has
to resolve to either one of them...

nibua-r

unread,
Mar 17, 2006, 11:05:11 AM3/17/06
to gnuplot-context
I mean texexec test & texmfstart *new*texexec test give same results

Hans Hagen

unread,
Mar 17, 2006, 11:39:11 AM3/17/06
to gnuplot...@googlegroups.com
just send me the mp file that fails and i can have a look

Hans Hagen

unread,
Mar 17, 2006, 11:40:47 AM3/17/06
to gnuplot...@googlegroups.com
maybe we should make mpto and makempx pluggable in metapost so that we can replace it by our own alternatives

Taco Hoekwater

unread,
Mar 17, 2006, 11:47:57 AM3/17/06
to gnuplot...@googlegroups.com

Hans Hagen wrote:
>
> maybe we should make mpto and makempx pluggable in metapost so that we can replace it by our own alternatives

They are pluggable: just change the search path before calling mpost.
But apart from that, it does make sense sometimes to write shorter
lines (long metapost paths can break buffer_size just as easily, and
that is not so easy to fix). Perhaps a \newif\ifshortMPlines ?

Cheers, Taco


Mojca Miklavec

unread,
Mar 17, 2006, 11:50:36 AM3/17/06
to gnuplot...@googlegroups.com
> > Verified. But I'm not versed enough in ruby to know what is wrong.
> >
> just send me the mp file that fails and i can have a look

The attached file fails to produce the correct label with newtexexec.

Mojca

abc.tex
abc-mpgraph.mp

Taco Hoekwater

unread,
Mar 17, 2006, 11:55:51 AM3/17/06
to gnuplot...@googlegroups.com

A problem with the new kpse code maybe? I am using that, and it
fails for me as well ...

Taco

Hans Hagen

unread,
Mar 17, 2006, 12:55:32 PM3/17/06
to gnuplot...@googlegroups.com
no, it's a bug in the code itself; (wrongly converted perl crap)

nibua-r

unread,
Mar 17, 2006, 1:03:56 PM3/17/06
to gnuplot-context
2006/3/17, Mojca Miklavec <mojca.mikl...@gmail.com>:
> I just wanted to ask about advantages over svn for example (It would
> be more trivial to use svn or cvs for me, but since there are no more
> than 4 people interested in it, it doesn't make that much difference).

The following link explain how darcs works
http://darcs.net/fosdem_talk/talk.pdf
See http://darcs.net/DarcsWiki section Darcs for Converts for the
differences between darcs and cvs/svn/arch

The main advantage (for me ;) ) is that I have already a darcs repo
ready to receive your project and I use it for my personal projects...

darcs can be used with darcsweb (like I do)
http://auriga.wearlab.de/~alb/darcsweb/
You can see how it looks like here
http://divineinvasion.net/darcsweb/darcsweb.cgi
Moreover, darcsweb provides RSS live bookmarks (can be usefull to
quickly check in firefox what's new on the repo).

Hans Hagen

unread,
Mar 17, 2006, 3:15:20 PM3/17/06
to gnuplot...@googlegroups.com
can you check the attached file?

newtexexec --mptex abc.mp

(btw, it runs 2 sec faster than the perl variant on my not to fast machine)

texrb.zip

Mojca Miklavec

unread,
Mar 17, 2006, 3:26:37 PM3/17/06
to gnuplot...@googlegroups.com
On 3/17/06, Hans Hagen wrote:
> can you check the attached file?
>
> newtexexec --mptex abc.mp
>
> (btw, it runs 2 sec faster than the perl variant on my not to fast machine)
>
> Hans

I might have done something wrong inbetween, but If I use texexec.pl
the plain tex is invoked for typesetting the label and if I use
newtexexec.rb (I just replaced the old tex.rb file with the new one) I
still get "unknown".

Mojca

Reply all
Reply to author
Forward
0 new messages