[pstricks] nodes and plot
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Thu Jan 22 20:47:01 CET 2004
Christophe Jorssen wrote:
>>If you still are interested in a file solution, let me know.
>>I have it run.
>
>
> I'm interested by your solution, thanks. I think I misunderstood what your
> explained...
I 'm working on a solution without writing the values into a
file. I have the problem that the nodes must be defined
as /N@<m>... inside PostScript and I do not really know how
to handle such "dynamical" function names inside PostScript,
where m=0,1,2,3,....
Attached the "file" solution.
- build the ps-file.
- run once "gs file.ps", this is important otherwise
the data file is not successfully build.
- now you can run the TeX file as usual, as dvi/ps/pdf
just as you like. instead of the parametricplot I use
now the data records of the file with \fileplot
this is the only problem, that a PostScript interpreter
(e.g. ghostscript) is needed to save the data records.
Maybe that this is a real problem to what you where
looking for.
Herbert
\documentclass[a4paper]{article}
\usepackage{pstricks,pst-plot,pst-node,pst-key}
\SpecialCoor
\makeatletter
\newif\ifPst at saveData% write the coordinates into a file?
\define at key{psset}{saveData}[true]{%
\@nameuse{Pst at saveData#1}%
}
\psset{saveData=false}
%
\def\saveDataAsNodes{%
\psset{unit=1pt}
\typeout{Open file \FileName}
\openin 7 = \FileName
\newcount\nrepeat\nrepeat=\psk at plotpoints
\loop
\def\NodeName{N\the\nrepeat}
\ifnum\nrepeat>-1
\read 7 to \Data
\pnode(\Data){\NodeName}
\typeout{\NodeName ->> (\Data)}
\advance\nrepeat by -1
\repeat
\closein 7%
}
%
\def\parametricplot at i#1#2#3{%
\pst at killglue
\begingroup
\use at par
\@nameuse{beginplot@\psplotstyle}%
\ifPst at saveData\typeout{>>> saveData <<<}\else\typeout{>>> no
saveData <<<}\fi%
\addto at pscode{%
\ifPst at saveData
/Datei (\FileName) (w) file def
\fi
\psplot at init
/t #1 def
/t1 #2 def
/dt t1 t sub \psk at plotpoints div def
/xy {
#3
\pst at number\psyunit mul /x exch def
\pst at number\psxunit mul /y exch def
\ifPst at saveData
/xString x 10 string cvs def
/yString y 10 string cvs def
Datei xString writestring
Datei (, ) writestring
Datei yString writestring
Datei (\string\n) writestring
\fi
x y
} def%
}%
\gdef\psplot at init{}%
\@pstfalse
\@nameuse{testqp@\psplotstyle}%
\if at pst\parametricplot at ii\else\parametricplot at iii\fi
\ifPst at saveData
\addto at pscode{ Datei closefile }%
\fi
\endgroup
\ignorespaces}
\makeatother
\begin{document}
\begin{center}
\begin{pspicture}(-2,-2)(2,2)
\def\FileName{data.ps}%
\typeout{>>> Filename: \FileName <<<}%
% saveData=true saves all points as a x|y data pair.
\IfFileExists{\FileName}{%
\typeout{>>> \FileName\ exists <<<}%
\saveDataAsNodes%
\fileplot{\FileName}%
\psline[linecolor=red](N1)(N5)(N23)(N12)(N49)(N13)(N22)(N44)%
}{ \typeout{>>> \FileName\ doesn't exist <<<}%
\parametricplot[unit=3,saveData=true]{0}{360}{t sin t cos}%
}%
\end{pspicture}
\end{center}
\end{document}
--
http://www.pstricks.de/
More information about the PSTricks
mailing list