From: Hans Hagen <pragma@wxs.nl>
Subject: Re: present for mojca
Date: Thu, 05 Jan 2006 19:43:53 +0100 [thread overview]
Message-ID: <43BD68E9.5060606@wxs.nl> (raw)
In-Reply-To: <6faad9f00601050757g40bc141bqd01eb1d5e5ef9ab7@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3810 bytes --]
Mojca Miklavec wrote:
>I experience exactly the same problem here both under Windows and
>Linux. ^M should be replaced by some "newline". If I do that manually,
>the module works perfectly.
>
>
i hate locales
>A bit weird request (and not urgent at all since there are other ways
>to solve this): could "rotate=" be added to \externalfigure once in
>the distant future? The resulting graphs in postscript are rotated 90
>degrees counterclocwise.
>
>
>
hm, i have to think about it
>>maybe \def\par{; } also works here, i dunny how long gnuplot lines may be
>>
>>
>
>
>
did \def\par{;} work out ok?
>The problem is not in \def\par{} I guess. It doesn't have any
>influence on the way how input lines appear in the file. Even if I
>redefined the \par and put strange chars in there, it didn't have any
>influence.
>
>
strange, maybe i have a better tex binary
>I tried to play with \obeylines a bit, but without success. I managed
>to get ^E (0x05) instead of ^M in the gnuplot file if I redefined
>\endchar to be ^^L (if I remember correctly), but just anything else
>led to errors.
>
>Two not-so-important remarks:
>1. \immediate\write\scratchwrite{end}
>"end" should be changed into "quit" or even better: left out
>completely since gnuplot exits anyway after executing the script
>
>
ok, quit then
>2. The default file extension is .plt (instead of gpd; the ending
>really doesn't matter, but this one is recognized by default when you
>"open file" from gnuplot)
>
>
>
hm, we don't want to overwrite files, do we?
>
>Some terminals are more ugly than the others. The best idea to specify
>the terminal is really by placing it manually into
>\startGNUPLOTinclusion, not by prepending it automatically (as I asked
>first), since it can have some additional parameters (color,
>landscape, ...).
>
>
it's not prepended now; however, it makes sense to think about it
because in the case of mp we need a different treatment
>There are also "set terminal pdf" (only in the "latest" versions,
>perhaps not even included in the binaries), "set terminal png", "set
>terminal mp", "set terminal latex", ...
>
>Another humble request from me would be to support more than a single terminal:
>
>%%%%%
>\setupGNUPLOT[terminal=postscript] % should result in
>\immediate\write\scratchwrite{set output "\bufferprefix
>gnuplot-\GNUPLOTnumber.ps"}%
>...
>\convertGNUPLOTgraphic{\bufferprefix gnuplot-\GNUPLOTnumber}%
>% perhaps a better name, suggesting ps2pdf conversion
>
>
>%%%%%
>\setupGNUPLOT[terminal=pdf] % only recent; should result in
>
>\immediate\write\scratchwrite{set output "\bufferprefix
>gnuplot-\GNUPLOTnumber.pdf"}%
>% no postprocessing/conversion needed.
>
>%%%%%
>\setupGNUPLOT[terminal=png] % should result in
>
>\immediate\write\scratchwrite{set output "\bufferprefix
>gnuplot-\GNUPLOTnumber.png"}%
>% no postprocessing/conversion needed.
>
>%%%%%
>\setupGNUPLOT[terminal=mp] % should result in
>
>\immediate\write\scratchwrite{set output "\bufferprefix
>gnuplot-\GNUPLOTnumber.mp"}%
>% plus mpost + mptopdf postprocessing
>
>%%%%%
>\setupGNUPLOT[terminal=latex] % somewhat more tricky; should result in
>
>\immediate\write\scratchwrite{set output "\bufferprefix
>gnuplot-\GNUPLOTnumber.tex"}%
>% another auxilary file has to be used in this case with \documentclass ...
>% \begindocument ... \input \bufferprefix gnuplot-\GNUPLOTnumber.tex
>% and then processed with pdflatex; that's what I currently use: most
>beautiful results
>
>
>
that's a big list ... why isn't there a context mode?
>Thanks a lot,
> Mojca
>
>PS: Does this module really mean that I have no more excuses for not
>finishing my report(s) for physics in time? ;)
>
>
>
>
no, worse, you now can finish it faster
see attached file (bottom of file); should be enough to get your reports
done
Hans
[-- Attachment #2: m-gnuplot.tex --]
[-- Type: text/x-tex, Size: 4597 bytes --]
%D \module
%D [ file=m-gnuplot,
%D version=2006.01.04,
%D title=\CONTEXT\ Extra Modules,
%D subtitle=\GNUPLOT\ Inclusion,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
% todo: reuse (only if really needed)
% \enablemode[demo]
%D example:
%D
%D \starttyping
%D texexec --pdf --mode=demo m-gnuplot
%D \stoptyping
\unprotect
\ifx\operatingsystem\undefined \def\operatingsystem{unix} \fi % texexec will set that
\newcounter\GNUPLOTnumber
\def\startGNUPLOTinclusions
{\bgroup
\obeylines
\dostartGNUPLOTinclusions}
\def\dostartGNUPLOTinclusions#1\stopGNUPLOTinclusions
{\gdef\GNUPLOTinclusions{#1}%
\egroup}
\def\startGNUPLOTgraphic#1%
{\bgroup
\obeylines
\dostartGNUPLOTgraphic{#1}}
\def\dostartGNUPLOTgraphic#1#2\stopGNUPLOTgraphic
{\doglobal\increment\GNUPLOTnumber
\letgvalue{gpg:n:#1}\GNUPLOTnumber
\setgvalue{gpg:d:\GNUPLOTnumber}{#2}%
\egroup}
\def\useGNUPLOTgraphic
{\dodoubleempty\douseGNUPLOTgraphic}
\def\douseGNUPLOTgraphic[#1][#2]%
{\iffirstargument
\@EA\dodouseGNUPLOTgraphic % like \externalfigure[name][optional args]
\else
\@EA\redouseGNUPLOTgraphic % like \useMPgraphic{name}
\fi[#1][#2]}
\def\redouseGNUPLOTgraphic[#1][#2]#3%
{\dodouseGNUPLOTgraphic[#3][]}
\def\dodouseGNUPLOTgraphic[#1][#2]%
{\bgroup
\doifdefined{gpg:n:#1}
{\edef\GNUPLOTnumber{\getvalue{gpg:n:#1}}%
\edef\GNUPLOTfile {\bufferprefix gnuplot-\GNUPLOTnumber}%
\bgroup
% hm, gnuplot only seems to handle lf so we cannot use \mappartolineend
% also, in order to prevent fuzzy runs (or no runs) we add a ; to each line
\def\par{;\rawcharacter{10}}%
\immediate\openout\scratchwrite=\GNUPLOTfile.gpd
\immediate\write\scratchwrite{set terminal "\@@GNUPLOTmethod"}%
\immediate\write\scratchwrite{\GNUPLOTinclusions}%
\immediate\write\scratchwrite{set output "\GNUPLOTfile.\@@GNUPLOTsuffix"}%
\immediate\write\scratchwrite{\getvalue{gpg:d:\GNUPLOTnumber}}%
\immediate\write\scratchwrite{quit}%
\immediate\closeout\scratchwrite
\egroup
\processGNUPLOTgraphic
\convertGNUPLOTgraphic
\externalfigure[\@@GNUPLOTresult][#2]}%
\egroup}
% we assume pdf inclusion, eps wil be implemented when applicable
\def\setupGNUPLOT
{\dodoubleempty\getparameters[@@GNUPLOT]}
\def\processGNUPLOTgraphic
{\doifelse\operatingsystem{mswin}
{\executesystemcommand{start pgnuplot \GNUPLOTfile.gpd}} % start is needed else gp fails
{\executesystemcommand{gnuplot \GNUPLOTfile.gpd}}}
\def\convertGNUPLOTgraphic
{\doifsomething\@@GNUPLOThandle{\executesystemcommand{\@@GNUPLOThandle}}}
\def\defineGNUPLOThandle#1#2#3#4#5% name output suffix conversion-method result
{\setvalue{@@GNUPLOT-#1}{{#2}{#3}{#4}{#5}}}
\def\@@GNUPLOToutput{\filterfromvalue{@@GNUPLOT-\@@GNUPLOTmethod}41}
\def\@@GNUPLOTsuffix{\filterfromvalue{@@GNUPLOT-\@@GNUPLOTmethod}42}
\def\@@GNUPLOThandle{\filterfromvalue{@@GNUPLOT-\@@GNUPLOTmethod}43}
\def\@@GNUPLOTresult{\filterfromvalue{@@GNUPLOT-\@@GNUPLOTmethod}44}
\defineGNUPLOThandle{postscript}{postscript}{ps} {texmfstart newpstopdf \GNUPLOTfile.ps}{\GNUPLOTfile.pdf}
\defineGNUPLOThandle{ps} {postscript}{ps} {texmfstart newpstopdf \GNUPLOTfile.ps}{\GNUPLOTfile.pdf}
\defineGNUPLOThandle{pdf} {pdf} {pdf}{} {\GNUPLOTfile.pdf}
\defineGNUPLOThandle{metapost} {mp} {mp} {texmfstart mptopdf \GNUPLOTfile.mp}{\GNUPLOTfile-0.pdf}
\defineGNUPLOThandle{mp} {mp} {mp} {texmfstart mptopdf \GNUPLOTfile.mp}{\GNUPLOTfile-0.pdf}
\defineGNUPLOThandle{png} {png} {png}{} {\GNUPLOTfile.png}
\setupGNUPLOT[\c!method=ps]
\protect \doifnotmode{demo}{\endinput}
\starttext
\startGNUPLOTinclusions
set title "trigonometry"
\stopGNUPLOTinclusions
\startGNUPLOTgraphic{sin}
plot sin(x)
\stopGNUPLOTgraphic
\startGNUPLOTgraphic{cos}
plot cos(x)
\stopGNUPLOTgraphic
\useGNUPLOTgraphic{sin} \endgraf
\useGNUPLOTgraphic{cos} \endgraf
\useGNUPLOTgraphic[cos] \endgraf
\setupGNUPLOT[method=ps] \useGNUPLOTgraphic[sin][object=no,height=2cm] \blank
%setupGNUPLOT[method=pdf] \useGNUPLOTgraphic[sin][object=no,height=2cm] \blank
\setupGNUPLOT[method=png] \useGNUPLOTgraphic[sin][object=no,height=2cm] \blank
\setupGNUPLOT[method=mp] \useGNUPLOTgraphic[sin][object=no,height=2cm] \blank
\stoptext
[-- Attachment #3: Type: text/plain, Size: 139 bytes --]
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context
next prev parent reply other threads:[~2006-01-05 18:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-02 10:34 gnuplot for Mojca Peter Münster
2006-01-03 8:18 ` Mojca Miklavec
2006-01-03 17:49 ` Peter Münster
2006-01-03 20:27 ` Mojca Miklavec
2006-01-03 21:19 ` Hans Hagen
2006-01-03 21:22 ` Hans Hagen
2006-01-03 22:07 ` Hans Hagen
2006-01-03 22:41 ` Peter Münster
2006-01-04 8:55 ` Hans Hagen
2006-01-04 14:45 ` present for mojca Hans Hagen
2006-01-04 15:34 ` Tobias Burnus
2006-01-04 16:14 ` Hans Hagen
2006-01-05 15:57 ` Mojca Miklavec
2006-01-05 18:43 ` Hans Hagen [this message]
2006-01-06 12:35 ` Mojca Miklavec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43BD68E9.5060606@wxs.nl \
--to=pragma@wxs.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).