[pstricks] logarithmic scale

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Mon Jul 5 10:31:10 CEST 2004


jmpapy wrote:

> I assume that :
> 
> \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
> 
> is always in the document preamble. I should I proceed when I have 
> several plots with a different scale in a document.

it is also possible to have this one in the document
body. And you can redefine it several times.
You can also define something with optional
macros to reset logs, scaling, etc ...

see example, where the second plot doesn't use
the log option

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}
\usepackage{pstricks-add}

\makeatletter
\def\pst at scaleX{1 } % scaling the data recors
\def\pst at scaleY{1 }
\def\pst at PSopX{} % additional PostScript code
\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>
\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 [\%]}
   \readdata{\data}{sv1_2_5.dat}
%
   \makeatletter\def\pst at PSopY{log}\makeatother
%
   \listplot[linewidth=0.5pt]{\data}
\end{pspicture}

\clearpage

\psset{xunit=3cm, yunit=1cm, xyLabel={\scriptsize\sffamily}}
\begin{pspicture}[](-0.5,-1)(3,10)
   \psaxes[axesstyle=frame,Dx=0.5](2.8284,10)
   \rput(1.5,-1){Noise Standard Deviation}
   \rput{90}(-0.4,5){\small\sffamily RRMSE [\%]}
   \readdata{\data}{sv1_2_5.dat}
%
   \makeatletter\def\pst at PSopY{}\makeatother% reset the log option
%
   \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




More information about the PSTricks mailing list