Hi everyone, I'm currently learning how to use the gnuplot module (thank you Mojca, and all the others, for this great tool!). I stick for now with the metapost terminal, as I'm not sure I'd be able to recompile gnuplot in order to add the context terminal. It seems that accents are not supported in gnuplot scripts. In the example below, both the methods to typeset accents fail. Is there a solution to this? Maybe there is something wrong with my settings... Best regards, Morgan \usemodule[gnuplot] \setupGNUPLOT[terminal=mp] \startGNUPLOTscript[sin] set xlabel "héllo h\'ello" plot sin(x) \stopGNUPLOTscript \starttext \useGNUPLOTgraphic[sin] \stoptext
Here's a short summary for Hans (or Taco), so that he doesn't need to read any further: - is it possible to have the contents between \startGPscript ... \stopGPscript go verbatim to the temporary file instead of having to be parsed? - Is there a way to get UTF-8 accented latin characters out of plain metapost files when using mptopdf? On Mon, Mar 24, 2008 at 3:38 PM, Morgan Brassel wrote:
Hi everyone,
Hello Morgan,
I'm currently learning how to use the gnuplot module (thank you Mojca, and all the others, for this great tool!). I stick for now with the metapost terminal, as I'm not sure I'd be able to recompile gnuplot in order to add the context terminal.
Which platform are you using?
It seems that accents are not supported in gnuplot scripts. In the example below, both the methods to typeset accents fail. Is there a solution to this? Maybe there is something wrong with my settings...
\usemodule[gnuplot] \setupGNUPLOT[terminal=mp] \startGNUPLOTscript[sin] set xlabel "héllo h\'ello" plot sin(x) \stopGNUPLOTscript \starttext \useGNUPLOTgraphic[sin] \stoptext
I'm afraid that the problem lies in metapost terminal ... Well, there are two problems, to be honest. Problem #1: is a "Hans please help" kind of problem. If you take a look into filename-gnuplot-1.plt you will spot: set xlabel "héllo h\dochar {233}llo" This can be solved by using set xlabel \detokenize{"héllo h\'ello"} in the your script or by convincing Hans or Taco to fix that problem (the content between \startGNUPLOTscript goes through some non-perfect modified TeX parser while it should be copied verbatim to the output file, but I have no idea how to fix that). \detokenize is just an ugly workaround. However, even if you fix that, you're still stuck. Problem #2: is a "sorry, mp terminal is limited" kind of problem. Let's take a look at filename-gnuplot-1-mp.mp after you fix the above mentioned problem: /.../ %font changes verbatimtex \def\setfont#1#2{%. \font\gpfont=#1 at #2pt \gpfont} \setfont{cmr10}{10.00} etex /.../ put_text( btex héllo h'ello etex, 635.3a, 18.3b, 0, 2); The first é doesn't work since metapost's btex doesn't know about utf-8 characters. I suspect there might be some solution to that if you convince mptopdf to respect UTF-8 input encoding on one hand and default font encoding on the other hand, so that é won't be taken from characters >127, but faked instead. I have no idea how to solve the input encoding problem (you could modify the mptopdf format, but there must be some other way - I guess that it is solvable). With font encoding you would have one problem less if \setfont{cmr10}{10.00} could be replaced by \setfont{ec-lmr10}{10.00} or even better - left out at all, but well - you would need to patch the metapost terminal for that or do some postprocessing or add another verbatimtex or ... The second \' doesn't work because metapost apparently eats all the backslashes for some stupid "security" reason. I could send you a patch for both problems, but it would mean: - that you would have problems every time you would use another gnuplot binary - you would need to recompile gnuplot binary anyway The problems mentioned under #2 are just a few among many other reasons why I have written the context terminal. Mojca PS: I'm CC-ing to Ethan in case he has some proposal about what could be done with metapost terminal to support UTF-8 (one of the best thing to do would be to remove cmr, but more is needed), and I'm CC-ing to the developer of the new TikZ terminal (for no specific reason).
On Mon, Mar 24, 2008 at 4:53 PM, Mojca Miklavec wrote:
The problems mentioned under #2 are just a few among many other reasons why I have written the context terminal.
I forgot to say: TikZ is the only other terminal that I know of and that (has a potential to) work reasonably well under ConTeXt, supporting both TeX sugars and high quality output, but: - it is not (yet) adapted to ConTeX (I hope it will be) - you would need to recompile gnuplot anyway - the chances to get either of the two terminals into the gnuplot core are just about equal - using either of them is equally non-portable at the moment Mojca
On Mon, 24 Mar 2008, Mojca Miklavec wrote:
Here's a short summary for Hans (or Taco), so that he doesn't need to read any further: - is it possible to have the contents between \startGPscript ... \stopGPscript go verbatim to the temporary file instead of having to be parsed? - Is there a way to get UTF-8 accented latin characters out of plain metapost files when using mptopdf?
On Mon, Mar 24, 2008 at 3:38 PM, Morgan Brassel wrote:
Hi everyone,
Hello Morgan,
I'm currently learning how to use the gnuplot module (thank you Mojca, and all the others, for this great tool!). I stick for now with the metapost terminal, as I'm not sure I'd be able to recompile gnuplot in order to add the context terminal.
Which platform are you using?
Hi Mojca, and thanks for your quick (and detailed) reply, I'm using debian sid with default ConTeXt, texlive, and gnuplot packages. Not trying to compile gnuplot myself is probably a matter of lazyness, as it should not be too difficult with debian packaging tools available. I guess the best solution for me is to try and test the 'context' terminal. Of course, it would be great to see some of the enhancements you describe appear, even if it is well above my understanding... Best wishes, Morgan
On Mon, Mar 24, 2008 at 5:35 PM, Morgan Brassel wrote:
Hi Mojca, and thanks for your quick (and detailed) reply,
I'm using debian sid with default ConTeXt, texlive, and gnuplot packages. Not trying to compile gnuplot myself is probably a matter of lazyness, as it should not be too difficult with debian packaging tools available. I guess the best solution for me is to try and test the 'context' terminal.
I don't know how to do it "the debian way", but an universal (less-Debian-like) way to recompile gnuplot it is to download gnuplot from sourceforge, add a line to include context terminal, and compile with ./configure make as described on http://wiki.contextgarden.net/Gnuplot. I have PATH=.:~/bin:/usr/bin ... so I simply copy my own version of gnuplot under ~/bin/gnuplot and the rest of the system remains intact. You do not need to "destroy your system" to make it work. Mojca
On Monday 24 March 2008 08:53, Mojca Miklavec wrote:
PS: I'm CC-ing to Ethan in case he has some proposal about what could be done with metapost terminal to support UTF-8 (one of the best thing to do would be to remove cmr, but more is needed), and I'm CC-ing to the developer of the new TikZ terminal (for no specific reason).
Gnuplot's metapost terminal correctly passes through UTF-8 characters to the output. Metapost itself then mangles them. If there is some additional keyword or command that gnuplot could emit that would allow metapost to do better, please let me know. Otherwise I think this problem must be resolved by using a different toolchain, one that is UTF-8 aware. Mojca: If the context terminal allows UTF-8 strings to be properly handled by TeX, for me that's a strong argument in favor of including it in the next gnuplot release. Does it? Ethan -- Ethan A Merritt
On Mon, Mar 24, 2008 at 7:52 PM, Ethan Merritt
On Monday 24 March 2008 08:53, Mojca Miklavec wrote:
PS: I'm CC-ing to Ethan in case he has some proposal about what could be done with metapost terminal to support UTF-8 (one of the best thing to do would be to remove cmr, but more is needed), and I'm CC-ing to the developer of the new TikZ terminal (for no specific reason).
Gnuplot's metapost terminal correctly passes through UTF-8 characters to the output.
That's right.
Metapost itself then mangles them.
That's also right. Actually, "btex label etex" which calls TeX (in an extremely inefficient way, among other things) is the one that doesn't know how to handle them. It would be nice if someone from this mailing list had at least some idea if that is solvable or not. Maybe harcoding utf-8 it into mptopdf could help, but that's far from being a nice solution, and has other undesired side-effects, so it's probably not really desired. Yet another solution would be to add some more commands to verbatimtex ... etex, but I don't see how to do that in some portable way. For example, metapost terminal already tries to be clever in some cases, and then loads obsolete (not to say not-existing-any-more-on-my-computer) fonts.
If there is some additional keyword or command that gnuplot could emit that would allow metapost to do better, please let me know.
OK, I will let you know if someone will come up with some idea.
Otherwise I think this problem must be resolved by using a different toolchain, one that is UTF-8 aware.
Mojca:
If the context terminal allows UTF-8 strings to be properly handled by TeX, for me that's a strong argument in favor of including it in the next gnuplot release. Does it?
Of course. "Anything" that ConTeXt suports can be supported in those labels now, including UTF-8. UTF-8 was one of the main reasons why PostScript terminal was almost out of question for me. Two years ago Hans and Taco "could not sleep" because of my requests & complaints, and they have made some major (great) improvements in ConTeXt and metapost code: labels processing became more reliable and about 100 times faster, and will improve even more with TeX Live 2008 and mplib. Those improvements are also the main reason why terminal didn't work in teTeX (but should work without problems in TeX Live 2007, which should become part of most Linux distributions by now). If you are willing to consider inclusion of the context terminal - may I ask you for your opinion about this terminal as well: http://peter.affenbande.org/gnuplot/ We're having some conversation with Peter about the possibilities to make his Lua-based TikZ terminal portable across plain TeX/LaTeX/ConTeXt formats, while TikZ itself is portable across dvips/pdfTeX (LuaTeX)/XeTeX engines. His terminal is much more popular than mine (there are more LaTeX users around than there are ConTeXt users), but the terminal has a dependency on Lua. However, any further conversation about this should better be moved off-list or to gnuplot-beta. Thanks a lot, Mojca
Mojca Miklavec wrote:
That's also right. Actually, "btex label etex" which calls TeX (in an extremely inefficient way, among other things) is the one that doesn't know how to handle them. It would be nice if someone from this mailing list had at least some idea if that is solvable or not.
don't bother too much about these issues ... in mkiv things will be different i'm currently playing with mplib; the default converter works ok; the specials handler is reimplemented and mostly finished; and now i'm playing with the textual part ... i even got this working ... \startMPgraphic fill fullcircle scaled 10cm withcolor green ; n := 50 ; for i=1 upto n : draw btex goodbye world etex scaled 2 rotatedaround(origin,i*360/n) ; endfor ; \stopMPgraphic so, btex/etex works ok in a loop; everything happpens in luatex/mplib it's even acceptable fast ... 100 times the previous graphic (i.e. 5000 btex/etex's) takes .7 seconds on my machine ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On Mon, Mar 24, 2008 at 11:02 PM, Hans Hagen wrote:
Mojca Miklavec wrote:
That's also right. Actually, "btex label etex" which calls TeX (in an extremely inefficient way, among other things) is the one that doesn't know how to handle them. It would be nice if someone from this mailing list had at least some idea if that is solvable or not.
don't bother too much about these issues ... in mkiv things will be different
It was about plain metapost. Will your tricks also possible when running "plain metapost" (mptopdf)?
i'm currently playing with mplib; the default converter works ok; the specials handler is reimplemented and mostly finished; and now i'm playing with the textual part ... i even got this working ...
\startMPgraphic fill fullcircle scaled 10cm withcolor green ; n := 50 ; for i=1 upto n : draw btex goodbye world etex scaled 2 rotatedaround(origin,i*360/n) ; endfor ; \stopMPgraphic
so, btex/etex works ok in a loop; everything happpens in luatex/mplib
it's even acceptable fast ...
100 times the previous graphic (i.e. 5000 btex/etex's) takes .7 seconds on my machine
Twice "wow" :) (After knowing the timings from the old-good-pre-sometxt times.) Thanks a lot, Mojca
Mojca Miklavec wrote:
On Mon, Mar 24, 2008 at 11:02 PM, Hans Hagen wrote:
Mojca Miklavec wrote:
That's also right. Actually, "btex label etex" which calls TeX (in an extremely inefficient way, among other things) is the one that doesn't know how to handle them. It would be nice if someone from this mailing list had at least some idea if that is solvable or not.
don't bother too much about these issues ... in mkiv things will be different
It was about plain metapost. Will your tricks also possible when running "plain metapost" (mptopdf)?
at some point mptopdf will use mkiv code (in context mkiv i will provide multiple engines .. \startMPgraphic[plain] ... \startMPgraphic[metafun] ...
Twice "wow" :) (After knowing the timings from the old-good-pre-sometxt times.)
btw, the latest textest already uses some of the same principles, but is slower since it still uses the external mp 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 -----------------------------------------------------------------
Hi everyone, Hi Mojca, I finally compiled gnuplot with support for the context terminal. It was really easy in the end, I should not have been afraid... I have two questions however (see example below): * Does the option 'solid' work with the context terminal? I still get dashed lines here... * ' and " quotes do not give the same result when UTF-8 character are involved. Is it wanted? Best regards, Morgan \enableregime[utf] \usemodule[gnuplot] \setupcolors[state=start] \setupGNUPLOT[options=color solid] \startGNUPLOTscript[sin] set ylabel "héllo" set xlabel 'héllo' plot sin(x), sin(2*x) \stopGNUPLOTscript \starttext \useGNUPLOTgraphic[sin] \stoptext
On Tue, Mar 25, 2008 at 3:28 PM, Morgan Brassel wrote:
Hi everyone, Hi Mojca,
I finally compiled gnuplot with support for the context terminal. It was really easy in the end, I should not have been afraid...
I have two questions however (see example below):
* Does the option 'solid' work with the context terminal? I still get dashed lines here...
Ok, that's part of lack of documentation on my part :) help term context says: ---- In non-standalone (`input`) graphic only parameters `size` to select graphic size, `textscale` to scale all the labels for a factor <scale> and `pointswithtex`/`pointswithmetapost` make sense, the rest is silently ignored and should be configured in the .tex file which inputs the graphic. ---- You can use \setupGNUPLOTterminal [context] [dashed=no, textscale=0.9] or similar. The reason why I have implemented it that way is: - you can reuse the same graphics by only turning that option on and off in the terminal, you don't need to rerun gnuplot - it's clumsy to provide explicit options to the terminal anyway, using an interface is easier - the option solid is only respected when you say 'standalone'
* ' and " quotes do not give the same result when UTF-8 character are involved. Is it wanted?
No. It's the same problem that I have mentioned last time. If you take a look at filename-gnuplot-1.plt you will see: set ylabel "h\dochar {233}llo" set xlabel 'h\dochar {233}llo' The second case gets literally to the output file, but then ConTeXt interprets it OK again. In the first case backslash is lost, and you get nonsense. This can be solved by using \detokenize as descriibed last time, but then again - it would be best if Taco or Hans or someone else had an idea of how to prevent that weird expansion inside \startGNUPLOTscript. I always use simple quotes for no particular reason (or maybe because I sometimes want to use \bf or other commands with backslash). Mojca
\enableregime[utf] \usemodule[gnuplot] \setupcolors[state=start] \setupGNUPLOT[options=color solid]
\startGNUPLOTscript[sin] set ylabel "héllo" set xlabel 'héllo' plot sin(x), sin(2*x)
\stopGNUPLOTscript
\starttext \useGNUPLOTgraphic[sin] \stoptext
You can use
\setupGNUPLOTterminal [context] [dashed=no, textscale=0.9]
Thank you, Mojca! The dashed option is ok, but I didn't manage to have 'textscale' work: adding these lines in my previous example still gives 12pt font... Am I missing something?
* ' and " quotes do not give the same result when UTF-8 character are involved. Is it wanted?
No. It's the same problem that I have mentioned last time. If you take a look at filename-gnuplot-1.plt you will see:
set ylabel "h\dochar {233}llo" set xlabel 'h\dochar {233}llo'
The second case gets literally to the output file, but then ConTeXt interprets it OK again. In the first case backslash is lost, and you get nonsense. This can be solved by using \detokenize as descriibed last time, but then again - it would be best if Taco or Hans or someone else had an idea of how to prevent that weird expansion inside \startGNUPLOTscript. I always use simple quotes for no particular reason (or maybe because I sometimes want to use \bf or other commands with backslash).
Sorry to make you explain again, I'm a bit lost with all those new things... I'll use simple quotes from now on, but is there a simple way to escape the ' character in this case? I tried set xlabel 'I\'\ m sorry!' but the ' is not typeset correctly then. A big thanks for your great patience! Morgan
On Tue, Mar 25, 2008 at 4:57 PM, Morgan Brassel wrote:
You can use
\setupGNUPLOTterminal [context] [dashed=no, textscale=0.9]
Thank you, Mojca!
The dashed option is ok, but I didn't manage to have 'textscale' work: adding these lines in my previous example still gives 12pt font... Am I missing something?
Whoooops ... apparently I forgot to upload that change. Sorry - I have no idea when I did it without uploading it. I will upload it now.
Sorry to make you explain again, I'm a bit lost with all those new things... I'll use simple quotes from now on, but is there a simple way to escape the ' character in this case? I tried
I guess not. But the fact that double quotes don't work is really a bug in my module that I don't know how to solve. If you use XeTeX, the UTF-8 should work OK, but sooner or later other problems might arise anyway (I always try to keep my fingers crossed that it will work). On the other hand, you may also run gnuplot separately and prepare "clean" files there. Then, you can use \processGNUPLOTfile[NAME][filename] % name of the generated file, not of the gnuplot script and later on \useGNUPLOTgraphic[NAME][maybe some options]
set xlabel 'I\'\ m sorry!'
but the ' is not typeset correctly then.
Mojca
Am 2008-03-25 um 18:11 schrieb Mojca Miklavec:
On Tue, Mar 25, 2008 at 4:57 PM, Morgan Brassel wrote:
set xlabel 'I\'\ m sorry!'
If UTF-8 works, why don’t you just use a proper apostrophe (’ vs. ') then? Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer)
Hi, This thread is a bit confusing to me, so if there is an actual question to me, someone has to rephrase it (and keep in mind that I have not used gnuplot in 'ages'). Mojca Miklavec wrote:
set ylabel "h\dochar {233}llo"
Should this not be set ylabel "h\\dochar {233}llo" because of GNUplot's own double-quoted string parsing? Independent of expansion in \startGNUPLOTscript, I mean? Speaking as the maintainer of Metapost, assuming 'plain.mp': you should be able to use UTF-8 in btex ... etex under the following (narrow) conditions: * you have set up the verbatimtex .. etex properly so that your macro package nows how to handle the UTF-8 input; * your tex engine generates DVI files * the resulting fonts that are used in that DVI are TFM-based. For context, that would mean mkii pdftex with \enableregime[utf], but in that case, you are much better off using \textext. You cannot have UTF-8 in literal metapost label strings, because Metapost only knows about traditional TFM fonts (single byte). Best wishes, Taco
On Wed, Mar 26, 2008 at 9:05 AM, Taco Hoekwater wrote:
Hi,
This thread is a bit confusing to me, so if there is an actual question to me, someone has to rephrase it (and keep in mind that I have not used gnuplot in 'ages').
Yes, I have two questions (that have been discussed at the begining of development already). 1.) here's a minimal example: \enableregime[utf] \usemodule[gnuplot] \setupGNUPLOT[terminal=mp] % so that you don't need to use the special binary \startGNUPLOTscript[sin] set xlabel 'héllo' plot sin(x), sin(2*x) t '$sin(2x)$' \stopGNUPLOTscript \startGNUPLOTscript[cos] # this comment doesn't work set xlabel 'héllo' plot cos(x) \stopGNUPLOTscript \starttext \useGNUPLOTgraphic[sin] \useGNUPLOTgraphic[cos] \stoptext Now, run texexec filename and take a look at filename-gnuplot-1.plt The second example needs to be commented out anyway as it fails completely. The problem is that the content of between GNUPLOTscript should be copied *verbatim* to .plt file. Now it goes through some semi-modified TeX parser that usually screws up some non-trivial cases (or, better said, only trivial cases work OK). If there existed some \startbuffer[name][continue], then it could be misused to put the content between GNUPLOTscript literally to that plt file. However, I have already been asking about how to do that (already in the time when line endings were screwed up) and there has been no real conclusion made so far. I guess it is possible, otherwise buffers and verbatim would not work, but I have no idea how to do that. Question 1a would probably be how to do that in mkiv, but that's not such a high priority as fixing the "bug" in the old code.
Mojca Miklavec wrote:
set ylabel "h\dochar {233}llo"
Should this not be
set ylabel "h\\dochar {233}llo"
It should. But it's not me the one who has put that junk to the .plt file :) :) :) ConTeXt does some weird thing with characters and puts "\dochar {233}" instead of "é" into the .plt file. (Almost) "the same thing" (printed \dochar) has happened to me a few times when using verbatim in ConTeXt (but got fixed).
because of GNUplot's own double-quoted string parsing? Independent of expansion in \startGNUPLOTscript, I mean?
True, but how are you going to convince TeX (ConTeXt) to put double backslash there?
Speaking as the maintainer of Metapost, assuming 'plain.mp': you should be able to use UTF-8 in btex ... etex under the following (narrow) conditions:
* you have set up the verbatimtex .. etex properly so that your macro package nows how to handle the UTF-8 input; * your tex engine generates DVI files * the resulting fonts that are used in that DVI are TFM-based.
For context, that would mean mkii pdftex with \enableregime[utf], but in that case, you are much better off using \textext.
2.) So - how should the (plain) metapost file look like and how should mptopdf be called, so that utf-8 would work OK in some portable-enough way? (\'e works OK there, it was only one backslash missing.)
You cannot have UTF-8 in literal metapost label strings, because Metapost only knows about traditional TFM fonts (single byte).
That's fine. I do not need metapost label strings. Thanks a lot, Mojca
On Mon, Mar 24, 2008 at 3:38 PM, Morgan Brassel
Hi everyone,
I'm currently learning how to use the gnuplot module (thank you Mojca, and all the others, for this great tool!). I stick for now with the metapost terminal, as I'm not sure I'd be able to recompile gnuplot in order to add the context terminal.
It seems that accents are not supported in gnuplot scripts. In the example below, both the methods to typeset accents fail. Is there a solution to this? Maybe there is something wrong with my settings...
Best regards, Morgan
\usemodule[gnuplot] \setupGNUPLOT[terminal=mp] \startGNUPLOTscript[sin] set xlabel "héllo h\'ello"
Try: set xlabel \detokenize{"h\\'ello"} Actually, one needs to escape backslash in gnuplot (that's a general rule). I'm sorry for not noticing that fact before. Just keep in mind that \detokenize is an ugly workaround (you could consider it a bug in t-gnuplot.tex, but I have no idea how to fix it). It would be easiest if \startbuffer[name][continue/append] some werbatim text \stopbuffer would work - then I would misuse that mechanism instead of doing dirty catcode changes. (I also need to ask either magician for help to port that part to mkiv; in XeTeX it seems to work OK.)
plot sin(x) \stopGNUPLOTscript \starttext \useGNUPLOTgraphic[sin] \stoptext
Mojca
participants (6)
-
Ethan Merritt
-
Hans Hagen
-
Henning Hraban Ramm
-
Mojca Miklavec
-
Morgan Brassel
-
Taco Hoekwater