ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: present for mojca
Date: Wed, 04 Jan 2006 15:45:19 +0100	[thread overview]
Message-ID: <43BBDF7F.5090302@wxs.nl> (raw)
In-Reply-To: <Pine.LNX.4.58.0601032331400.31660@gaston.free.fr>

[-- Attachment #1: Type: text/plain, Size: 34 bytes --]

see attached file for usage

Hans

[-- Attachment #2: m-gnuplot.tex --]
[-- Type: text/x-tex, Size: 3142 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}}%
      \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=\bufferprefix gnuplot-\GNUPLOTnumber.gpd
      \immediate\write\scratchwrite{\GNUPLOTinclusions}%
      \immediate\write\scratchwrite{set output "\bufferprefix gnuplot-\GNUPLOTnumber.ps"}%
      \immediate\write\scratchwrite{\getvalue{gpg:d:\GNUPLOTnumber}}%
      \immediate\write\scratchwrite{end}%
      \immediate\closeout\scratchwrite
      \egroup
      \processGNUPLOTgraphic{\bufferprefix gnuplot-\GNUPLOTnumber}%
      \convertGNUPLOTgraphic{\bufferprefix gnuplot-\GNUPLOTnumber}%
      \externalfigure[\bufferprefix gnuplot-\GNUPLOTnumber.pdf][#2]}%
   \egroup}

% we assume pdf inclusion, eps wil be implemented when applicable

\def\processGNUPLOTgraphic#1%
  {\doifelse\operatingsystem{mswin}
     {\executesystemcommand{start pgnuplot #1.gpd}} % start is needed else gp fails
     {\executesystemcommand{gnuplot #1.gpd}}}

\def\convertGNUPLOTgraphic#1%
  {\executesystemcommand{texmfstart newpstopdf #1.ps}}

\protect \doifnotmode{demo}{\endinput}

\starttext

\startGNUPLOTinclusions
    set title "trigonometry"
    set terminal postscript
\stopGNUPLOTinclusions

\startGNUPLOTgraphic{sin}
    plot sin(x)
\stopGNUPLOTgraphic

\startGNUPLOTgraphic{cos}
    plot cos(x)
\stopGNUPLOTgraphic

\useGNUPLOTgraphic{sin}

\useGNUPLOTgraphic{cos}

\useGNUPLOTgraphic[cos]

\useGNUPLOTgraphic[sin][height=3cm]

\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

  parent reply	other threads:[~2006-01-04 14:45 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           ` Hans Hagen [this message]
2006-01-04 15:34             ` present for mojca Tobias Burnus
2006-01-04 16:14               ` Hans Hagen
2006-01-05 15:57                 ` Mojca Miklavec
2006-01-05 18:43                   ` Hans Hagen
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=43BBDF7F.5090302@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).