[pstricks] Error bars and pstScalePoints

Herbert Voss LaTeX at zedat.fu-berlin.de
Tue Jul 11 13:30:57 CEST 2006



Martin Buchmann wrote:

> I am still struggling with pstScalePoints and my error bars and I know 
> far to little to understand what is going on here.
> 
> I have checked the source of pstricks-add.tex to see how pstScalePoints 
> works with the listplot macro but I don't really get it :-)
> Is there a way to make \errorLine work with that? I know that I can 
> simply use (x|y)unit for the scaling but I need the third and forth 
> operator to add a fix value to all my data.

you can improve the example.

Herbert

\begin{filecontents}{minimal.dat}
0.3 116 -14 14
1.3 128 -16 16
2.4 133 -14 14
3.5 138 -15 15
4.6 141 -14 14
5.7 146 -16 16
6.9 143 -10 10
8.0 177 -22 22
9.0 218 -24 24
\end{filecontents}

\documentclass[11pt,a4paper]{article}

\usepackage{pstricks,pstricks-add}
\def\pshlabel#1{\sffamily #1}
\def\psvlabel#1{\sffamily #1}

\pagestyle{empty}

\makeatletter
\SpecialCoor
\def\errorLine{\@ifnextchar[{\pst at errorLine}{\pst at errorLine[]}}
\def\pst at errorLine[#1](#2)#3#4{{%
      \ifx#1\empty\else\psset{#1}\fi
      \pst at getcoor{#2}\pst at tempB
      \def\@errorMin{#3}
      \def\@errorMax{#4}
      \psline{|-|}%
      (!%
          /yDot \pst at tempB exch pop \pst at number\psyunit div 100 sub def
          /xDot \pst at tempB pop \pst at number\psxunit div def
          xDot yDot \@errorMin\space add%
      )(!%
          /yDot \pst at tempB exch pop \pst at number\psyunit div 100 sub  def
          /xDot \pst at tempB pop \pst at number\psxunit div def
          xDot yDot \@errorMax\space add%
      )
      \psdot[linecolor=black](!
          /yDot \pst at tempB exch pop \pst at number\psyunit div 100 sub def
          /xDot \pst at tempB pop \pst at number\psxunit div def
          xDot yDot )
}}
%
\def\GetCoordinates#1{\expandafter\GetCoordinates at i#1}
\def\GetCoordinates at i #1{\GetCoordinates at ii#1}
\def\GetCoordinates at ii#1 #2 #3 #4 #5 #6 #7 #8 {%
      \DoCoordinate{#2}{#4}%
      \errorLine[linecolor=red, 
linewidth=2pt,yunit=0.04](#2,#4){#6}{#8}% <<<<<
      \@ifnextchar D{\GetCoordinates at ii}{}%
}
\makeatother

\begin{document}

\begin{pspicture}(-1.75,-1.5)(11.0,9)
    \psaxes[axesstyle=frame,ticksize=5pt,Oy=100,Dy=20,dy=0.7998](10,8)
    \readdata{\Data}{minimal.dat}
    \def\DoCoordinate#1#2{\psdot(#1,#2)}%
    \GetCoordinates{\Data}
\end{pspicture}

\end{document}






More information about the PSTricks mailing list