[pstricks] \psgraph

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Mon Jul 5 12:54:46 CEST 2004


Hi,
in fact of the last thread I thought about a macro
\psgraph, which does the scaling of the axes, the
scaling of the data records (also log).

Here is my first try. Comments?

Herbert


\begin{filecontents}{nodes.total}
1 99447169
2 110351058
3 123557238
4 138346129
5 145050826
6 160363212
7 174000394
8 183856559
9 189128691
10 197634845
11 213257357
12 216899512
13 230152738
14 224144907
15 247410024
16 261168438
17 252920343
18 326153799
19 319442110
20 310351522
21 381919943
22 438043888
23 357527766
24 603304997
\end{filecontents}

\documentclass[a4paper,12pt]{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pstricks-add}
\usepackage{pst-key}
\pagestyle{empty}
\parskip=0pt

\makeatletter
\def\pst at scaleX{1 }
\def\pst at scaleY{1 }
\def\pst at PSopX{}
\def\pst at PSopY{}
\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 {
     \pst at PSopY\space y mul \pst at scaleY\space mul m 1 roll
     \pst at PSopX\space x mul \pst at scaleX\space mul m 1 roll
     /m m 2 sub
     def } repeat>
%
\define at key{psset}{xAxesLabel}{\edef\psk at xAxesLabel{#1}}
\define at key{psset}{yAxesLabel}{\edef\psk at yAxesLabel{#1}}
\define at key{psset}{xAxesLabelPos}{\edef\psk at xAxesLabelPos{#1}}
\define at key{psset}{yAxesLabelPos}{\edef\psk at yAxesLabelPos{#1}}
\psset{xAxesLabel=x,yAxesLabel=y,xAxesLabelPos=\@empty,yAxesLabelPos=\@empty}
%
\def\psgraph{\@ifnextchar[{\psgraph at i}{\psgraph at i[]}}
\def\psgraph at i[#1]{\@ifnextchar[{\psgraph at ii[#1]}{\psgraph at ii[#1][]}}
\def\psgraph at ii[#1][#2]{\@ifnextchar({\psgraph at iii[#1][#2]}{\psgraph at iii[#1][#2](1,1)}}
% Options | scaleX | scaleY
\def\psgraph at iii[#1][#2](#3,#4){%
   \edef\pst at scaleX{#3 }%
   \edef\pst at scaleY{#4 }%
   \psgraph at iv[#1][#2]%
}
\def\psgraph at iv[#1][#2]#3#4#5#6#7#8#9{{%
% options axes | option plot |data | maxX | maxY | Dx | Dy | Length 
x-axis | length y-axis%
   \pst at dima=#8
   \pst at dimb=#4sp
   \divide\pst at dima by \pst at dimb
   \pst at dimc=#9
   \pst at dimb=#5sp
   \divide\pst at dimc by \pst at dimb
   \psset{xunit=\pst at dima,yunit=\pst at dimc}
   \begin{pspicture}(#4,#5)
     \psaxes[Dx=#6,Dy=#7,#1](#4,#5)
     \ifx\psk at xAxesLabel\@empty\else
       \ifx\psk at xAxesLabelPos\@empty\relax
         \uput[0](#4,0){\psk at xAxesLabel}%
         \uput[90](0,#5){\psk at yAxesLabel}%
       \else
         \rput(\psk at xAxesLabelPos){\psk at xAxesLabel}%
         \rput{90}(\psk at yAxesLabelPos){\psk at yAxesLabel}%
       \fi
     \fi
     \listplot[#2]{#3}
   \end{pspicture}%
}}
\makeatother

\begin{document}




-- 
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes




More information about the PSTricks mailing list