[pstricks] Re: series of plots / pstricks
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Thu Jan 29 21:53:25 CET 2004
Dammerl wrote:
>>> is it possible to include a series of graphs in a \dataplot (or
>>> alike). Somethings like
>>>
>>> %datafile
>>> x y1 y2 y3 ...
>>> x y1 y2 y3 ...
>>> ...
>>>
>>> that gives 4+ independent graphs, without creating x amount of input
>>> files?
>>
>>
>>
>> give such a complete demo file.
>
>
> Herbert,
>
> this is a copy of a data file:
>
> [%
> 0 0 3,375 0,0625
> 10 5,375 7,1875 4,5
> 20 7,1875 8,375 6,25
> 30 5,75 7,75 6,6875
> 40 2,1875 5,75 5,9375
> 50 -1,9375 2,1875 4,3125
> 60 -5,125 -1,8125 0,875
> 70 -6,4375 -5,3125 -2,6875
> 80 -4,875 -7,1875 -4,875
> 90 0 -7,625 -5,625
> 100 5,5 -6,3125 -5,8125
> 110 6,8125 -2,75 -4,75
> 120 5,25 2,875 -0,75
> ]%
>
> The first column would be my x-axis, 2nd-4th would be 3 different graphs
> to that x values (later, I would like 12 or more different graphs). To
> create that many separate data files out of excel is quite cumbersome (I
> don't know if macros could help). Creating one with many columns though
> is very easy and fast.
Here is a solution which needs flowting point numbers
with a _dot_ instead of the comma.
Herbert
\documentclass[a4paper,12pt]{article}
\usepackage{pst-plot}
\makeatletter
\def\psset at plotNo#1{\edef\psk at plotNo{#1}}
\def\psset at plotNoMax#1{\edef\psk at plotNoMax{#1}}
\psset{plotNo=1,plotNoMax=1}
%
\def\listplot at ii#1{%
\@nameuse{beginplot@\psplotstyle}%
\addto at pscode{/D {} def mark}%
#1%
\addto at pscode{%
counttomark /m exch def
/n m \psk at plotNoMax\space 1 add div cvi def
n {
\psk at plotNoMax\space \psk at plotNo\space 1 sub neg roll % x yNo y y y ...
\psk at plotNoMax\space 1 sub { pop } repeat % x yNo
/m m \psk at plotNoMax\space 1 sub sub def
m 2 roll
} repeat
\pst at number\psxunit
\pst at number\psyunit
\tx at ScalePoints%
}%
\@nameuse{endplot@\psplotstyle}%
}
\makeatother
\readdata\Data{data.dat}% the above data as a file with dotted numbers!
\begin{document}
\psset{xunit=0.1cm, yunit=0.5cm}
\begin{pspicture}(0,-7.5)(150,7.5)
\psaxes[Dx=10,Dy=2]{->}(0,0)(0,-7.5)(150,7.5)
\psset{linewidth=2pt}
\listplot[plotNo=1,plotNoMax=3]{\Data}
\listplot[linecolor=red,plotNo=2,plotNoMax=3]{\Data}
\listplot[linecolor=blue,plotNo=3,plotNoMax=3]{\Data}
\end{pspicture}
\end{document}
More information about the PSTricks
mailing list