[pstricks] x,y-errorbars

Max Moritz Sievers max at enddeluxe.de
Wed Feb 15 00:31:40 CET 2006


Am Dienstag, 14. Februar 2006 23:07 schrieb Herbert Voss:
> it is nearly the same as for yMin/yMax ... Herbert

I presummed that but I'm not familiar with the syntax, so I couldn't do it 
myself.

Anyway, your solution is not exactly what I want. But comparing your 
dyMin,dyMax-code with your new dx,dy-code and guessing what the opposite of 
»add« is, I was able to get what I wanted:


\begin{filecontents}{DotErrorBar.dat}
1.5 48 0.25 20
2 66 0.25 17
2.5 74 0.25 12
\end{filecontents}

\documentclass[a4paper]{article}
\usepackage{pst-plot}
\usepackage{pst-node}
\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 tempA
     \def\@errorMin{#3}
     \def\@errorMax{#4}
     \psline[linewidth=1pt]{-|}(#2)(!%
         \pst at tempA \pst at number\psyunit div /yDot exch def
         \pst at number\psxunit div \@errorMin\space add yDot %
     )
     \psline[linewidth=1pt]{-|}(#2)(!%
         \pst at tempA \pst at number\psyunit div /yDot exch def
         \pst at number\psxunit div \@errorMin\space sub yDot %
     )
     \psline[linewidth=1pt]{-|}(#2)(!%
         \pst at tempA \pst at number\psyunit div \@errorMax\space add exch
         \pst at number\psxunit div exch %
     )
     \psline[linewidth=1pt]{-|}(#2)(!%
         \pst at tempA \pst at number\psyunit div \@errorMax\space sub exch
         \pst at number\psxunit div exch %
     )
}}
%
\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](#2,#4){#6}{#8}% <<<<<
     \@ifnextchar D{\GetCoordinates at ii}{}%
}
\makeatother
\pagestyle{empty}
\begin{document}

\readdata{\Data}{DotErrorBar.dat}
\psset{xunit=4,yunit=0.1}
\begin{pspicture}(0,0)(2.55,100)
   \psaxes[Dy=10,dy=1cm](0,0)(5,100)
   \def\DoCoordinate#1#2{\psdot(#1,#2)}%
   \GetCoordinates{\Data}
\end{pspicture}

%\show\Data% only for the log file

\end{document}


I am still surprised why apparently nobody had asked for it before me and I 
suggest to include this example to the next edition of your book.

-- 
regards
Max Moritz Sievers




More information about the PSTricks mailing list