[pstricks] Re: Spot the error

Herbert Voss Herbert.Voss at gmx.net
Sun Jul 4 18:10:44 CEST 2004


David Rasmussen wrote:
> I have this file:
> 
> \documentclass[a4paper,12pt]{report}
> \usepackage{pst-plot}
> \begin{document}
> 
> \newcommand{\graffig}[7]
> {
> \count0=#6
> \divide\count0 by #2
> \count1=#7
> \divide\count1 by #3
> 
> \scalebox{1}
> {
> \readdata{\mydata}{#1}
> \psset{xunit=\count0 cm,yunit=\count1 cm}
> \begin{pspicture}(#2,#3)
> \psaxes[axesstyle=frame,Dx=#4,Dy=#5](#2,#3)
> \listplot[plotstyle=line]{\mydata}
> \listplot[plotstyle=dots]{\mydata}
> \end{pspicture}
> }
> 
> }
> 
> \graffig{tu.total}{25}{100000}{1}{10000}{10}{10}
> 
> \end{document}
> 
> The tu.total contains this:
> 1 55808
> 2 31989
> 3 24884
> 4 22572
> 5 19718
> 6 17792
> 7 19529
> 8 17482
> 9 15658
> 10 18048
> 11 19132
> 12 19578
> 13 16152
> 14 16303
> 15 20265
> 16 24822
> 17 15240
> 18 19434
> 19 18585
> 20 19865
> 21 22418
> 22 23840
> 23 21704
> 24 39401
> 
> But the resulting dvi file only contains a dot. What is going wrong? If 
> I try to put hard values in manually instead of calculating them, 
> everything works fine.

this depends to the crazy behaviour of TeX, no "real" floating
point operations. PSTricks has its own counters.

Herbert


\begin{filecontents}{tu.total}
1 55808
2 31989
3 24884
4 22572
5 19718
6 17792
7 19529
8 17482
9 15658
10 18048
11 19132
12 19578
13 16152
14 16303
15 20265
16 24822
17 15240
18 19434
19 18585
20 19865
21 22418
22 23840
23 21704
24 39401
\end{filecontents}
%
\documentclass[a4paper,12pt]{report}
\usepackage{pst-plot}

\makeatletter
\newcommand{\graffig}[7]{%
   \pst at dima=#6
   \pst at dimb=#2sp
   \divide\pst at dima by \pst at dimb
   \pst at dimc=#7
   \pst at dimb=#3sp
   \divide\pst at dimc by \pst at dimb
   \scalebox{1}{%
     \readdata{\mydata}{#1}
     \psset{xunit=\pst at dima,yunit=\pst at dimc}
     \begin{pspicture}(#2,#3)
       \psaxes[axesstyle=frame,Dx=#4,Dy=#5](#2,#3)
       \listplot[showpoints=true]{\mydata}
     \end{pspicture}
   }%
}
\makeatother

\begin{document}

\graffig{tu.total}{25}{100000}{2.5}{10000}{10cm}{10cm}

\end{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