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

Denis Girou Denis.Girou at idris.fr
Sat May 18 23:44:09 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> thanks Denis, but my problem is that I'm looking for an
Herbert.Voss> example where _only_ listplot makes sense. For the
Herbert.Voss> above example you'll get exactly the same with

Herbert.Voss> \dataplot[showpoints=true,plotstyle=curve]{\DataB}

Herbert.Voss> If I understand the manual right, than it must be
Herbert.Voss> possible to put these postscript commands into
Herbert.Voss> \DataB.

Hum... In fact, this is not true "in general", but I agree that the
situation can be a little bit confuse, because it depend of several things
and because the situation is not very clearly described in the documentation.

In summary: \dataplot use in own way (called "quick plot") when it can,
and if not call \listplot. In our case here, \dataplot cannot use the "quick
plot", so only call \listplot. This is why we have here the same result.
But this is not true all the time. There are various criteriums which force
\dataplot to call \listplot. Here we have even two ones: the usage of the
"showpoint" parameter and of the "curve" style. Both are not supported by
"quick plots". But just using \dataplot without these options, so with the
default "line" value for "plotstyle", will do a "quick plot". It would use
a completely different way than \listplot, and among other changes in it
behavior will not accept PostScript code inside the data.

\def\dataplot at i#1{%
...
\@nameuse{testqp@\psplotstyle}%
\if at pst
\else
\fi

Herbert.Voss> ok, I got it. Here some code which is only possible
Herbert.Voss> with \listplot and not with the other two ones. The

You are wrong here. For the above reasons, \dataplot will also produce the
same result here, just calling \listplot at ii.

Herbert.Voss> only thing which I do not understand is why I get
Herbert.Voss> 7 points instead of the 6 with the second listplot
Herbert.Voss> command??

Herbert.Voss> \documentclass{article}
Herbert.Voss> \usepackage{pst-plot}
Herbert.Voss> \begin{document}
Herbert.Voss> \begin{pspicture}(6,7)
Herbert.Voss>    \psaxes{<->}(6,6)
Herbert.Voss>    \listplot[showpoints=true,plotstyle=curve]{%
Herbert.Voss>        0 1 0.5 3 1 5 1.5 1 3 4.5 5 0.5%
Herbert.Voss>    }
Herbert.Voss> \end{pspicture}

Herbert.Voss> \makeatletter
Herbert.Voss> \pst at def{ScalePoints}<> % clear old definition
Herbert.Voss> \makeatother
Herbert.Voss> \newcommand{\DataB}{%
Herbert.Voss>      0   1
Herbert.Voss>      0.5 3
Herbert.Voss>      1   5
Herbert.Voss>      1.5 1
Herbert.Voss>      3   4.5
Herbert.Voss>      5   0.5
Herbert.Voss> 28.45274 28.45274 /y ED /x ED
Herbert.Voss> counttomark dup dup cvi eq not { exch pop } if
Herbert.Voss> /m exch def /n m 2 div cvi def
Herbert.Voss>    n {
Herbert.Voss>       dup 3 gt {pop 3} if
Herbert.Voss>       y mul
Herbert.Voss>       m 1 roll
Herbert.Voss>       x mul
Herbert.Voss>       m 1 roll
Herbert.Voss>       /m m 2 sub
Herbert.Voss>       def } repeat
Herbert.Voss>      }
Herbert.Voss> \begin{pspicture}(6,7)
Herbert.Voss>    \psaxes{<->}(6,6)
Herbert.Voss>    \listplot[showpoints=true,plotstyle=curve]{\DataB}
Herbert.Voss> \end{pspicture}

Herbert.Voss> \end{document}

You got 7 points and not 6 only because you do not redefine things as
required. There are scaling values in the internal PostScript code, that will
remain on the stack and in this case will be used as another point.

\def\listplot at ii#1{%
...
\addto at pscode{\pst at number\psxunit \pst at number\psyunit \tx at ScalePoints}%

If you need to apply a computation on all the data, it is better to redefine
the ScalePoints accordingly, as I did it in my example, rather than to
suppress it and to reintroduce the modified PostScript code in the data
definition.

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                     |
--------------------------------------------------------------------------