# [pstricks] Re: pstricks (pst-plot) and listplot

Denis Girou Denis.Girou at idris.fr
Sat May 18 15:10:54 CEST 2002

The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "Herbert.Voss" == Herbert Voss <voss at perce.de> writes:

Herbert.Voss> I'm looking for an example for the use of
Herbert.Voss> \listplot[<parameter>]{<list>}

Herbert.Voss> which doesn't do the same than the other two
Herbert.Voss> plot commands fileplot and dataplot. <list>
Herbert.Voss> can have PostScript-commands which will be
Herbert.Voss> passed direct to the PostScript-interpreter.

I think that this can be useful in case of repetitive and automatic plots of
external data, when you want to pre-process these data without modifying them
explicitely. Of course, this can be done by an external program which reformat
the data and create a new file, but the \listplot command allow to do rather
directly some automatic changes in the data without requiring an external
process.

I give you here a simple example, where I decide that the y maximum value
must be 3. I just modify the ScalePoints PostScript macro, which is used to
loop inside the coordinates, to translate user ones into the PostScript ones.

Perhaps that somebody else would propose other convincing examples...

\documentclass[a4paper]{article}

\usepackage{pst-plot}

\setlength{\textwidth}{14cm}

\pagestyle{empty}

\begin{document}

\begin{pspicture}(6,7)
\psaxes{<->}(6,6)
\savedata{\DataA}[(0,1)(0.5,3)(1,5)(1.5,1)(3,4.5)(5,0.5)]
\dataplot[showpoints=true,plotstyle=curve]{\DataA}
\end{pspicture}
\hfill
\newcommand{\DataB}{%
0   1
0.5 3
1   5
1.5 1
3   4.5
5   0.5}
\begin{pspicture}(6,7)
\psaxes{<->}(6,6)
\listplot[showpoints=true,plotstyle=curve]{\DataB}
\end{pspicture}

\makeatletter

\pst at def{ScalePoints}<%
/y ED /x ED
counttomark dup dup cvi eq not { exch pop } if
/m exch def /n m 2 div cvi def
n {
% D.G. modification begin - May. 18, 2002
% If the y coordinate is greater than 3, we change it for 3
dup 3 gt {pop 3} if
% D.G. modification end
y mul
m 1 roll
x mul
m 1 roll
/m m 2 sub
def } repeat>

\makeatother

\begin{pspicture}(6,7)
\psaxes{<->}(6,6)
\listplot[showpoints=true,plotstyle=curve]{\DataB}
\end{pspicture}

\end{document}

Denis Girou
--
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------