[pstricks] x,y-errorbars

Herbert Voss LaTeX at zedat.fu-berlin.de
Tue Feb 14 23:07:26 CET 2006



Max Moritz Sievers wrote:
> Am Dienstag, 14. Februar 2006 19:39 schrieb Herbert Voss:
> 
>>give an exampla data set.
> 
> 
> x y dx dy
> 
> 1.5 48 0.25 20
> 2 66 0.25 17
> 2.5 74 0.25 12

it is nearly the same as for yMin/yMax ... Herbert

Herbert


\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=0.1pt]{-|}(#2)(!%
         \pst at tempA \pst at number\psyunit div /yDot exch def
         \pst at number\psxunit div \@errorMin\space add yDot %
     )
     \psline[linewidth=0.1pt]{-|}(#2)(!%
         \pst at tempA \pst at number\psyunit div \@errorMax\space add 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}






More information about the PSTricks mailing list