# [pstricks] logarithmic scale

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Mon Jul 5 08:21:08 CEST 2004

jmpapy wrote:
>
> Hello,
>
> I plotted some data using pstricks in linear scale. Here are the code
> and the data:

[ ... ]

> Now I would want to plot the same data in decimal log scale (for the y
> axis).

remember that \pst at def works only for \listplot

> \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 {
>       y mul log m 1 roll % <-- log of y

this gives the wrong value, because y ist _not_ the
y-value, it is the scaling factor! The x y data records
are saved in the stack list

yunit xunit y x y x y x y x y x ....

this is the reason why you have to write

log y mul m 1 roll % <-- log of y

means: first the log, then multiply it with the yunit

I also did some modification to your code. Just playing
around with it. You can reverse the changes.

Herbert

\begin{filecontents}{sv1_2_5.dat}
0.1414    0.0052
0.2828    0.0217
0.4243    0.0480
0.5657    0.0890
0.7071    0.1375
0.8485    0.1906
0.9899    0.2663
1.1314    0.3580
1.2728    0.4644
1.4142    0.5801
1.5556    0.7033
1.6971    0.8899
1.8385    1.1143
1.9799    1.2593
2.1213    1.5692
2.2627    3.2331
2.4042    4.4097
2.5456    5.8186
2.6870    7.4441
2.8284    8.2287
\end{filecontents}

\documentclass[12pt,a4paper]{article}
\usepackage{pstricks}
\usepackage{pst-plot}

\makeatletter
\pst at def{ScalePoints}<%
/y ED /x ED % save the units
counttomark dup dup cvi eq not { exch pop } if
/m exch def /n m 2 div cvi def
n {
log y mul m 1 roll % <-- log of y-value
x mul m 1 roll
/m m 2 sub
def } repeat>
\makeatother

\begin{document}

\psset{xunit=3cm, yunit=4cm, xyLabel={\scriptsize\sffamily}}
\begin{pspicture}[](-0.5,-1)(3,1)
\psaxes[axesstyle=frame,Dx=0.5,ylogBase=10,Oy=-4](0,-3)(2.8284,1)
\rput(1.5,-3.2){Noise Standard Deviation}
\rput{90}(-0.4,-1){\small\sffamily RRMSE [\%]}
\listplot[linewidth=0.5pt]{\data}
\end{pspicture}
\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