[pstricks] Errorbars in a logarithmic diagram

Herbert Voss Herbert.Voss at fu-berlin.de
Wed Oct 17 20:27:54 CEST 2007


Martin Buchmann schrieb:

> I want a to combine two things: A logarithmic x-axis and errorbars in x
> and y-direction.  I know how to do each of them separated but if I try
> to add the logarithmic part to the example
> 'DotErrorBar2.tex' and it seems not to be compatible with the usual
> 
> \pstScalePoints(5,23.333){ log 1 add }{ }

this works only for a listplot.

Herbert

\RequirePackage{filecontents}% allows overwriting
\begin{filecontents}{DotErrorBar.dat}
1.295  0.033  0.351  0.029
1.330  0.028  0.359  0.024
1.335  0.031  0.366  0.016
1.687  0.043  0.455  0.037
3.584  0.132  0.993  0.057
3.632  0.105  1.007  0.048
3.932  0.092  1.095  0.032
4.256  0.112  1.192  0.043
\end{filecontents}

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

\readdata{\Data}{DotErrorBar.dat}
\psset{xunit=5,yunit=20}
\begin{pspicture}(-1,-0.05)(1.2,0.32)
   \psaxes[Ox=-1,Dy=0.05,dy=1.00cm,
		logLines=x,xlogBase=10,
		xsubticks=10,ysubticks=2,
		yticksize=0 5pt]{->}(-1,0)(1.1,0.31)
   \def\DoCoordinate#1#2{\psdot[dotscale=2](!#1 log #2)}%
   \GetCoordinates{\Data}
% the following makes no sense, only for fun here
   \pstScalePoints(1,1){ log }{ }
   \listplot[plotstyle=curve,linecolor=blue,
		plotNoMax=3,plotNo=1]{\Data}
\end{pspicture}

\end{document}




More information about the PSTricks mailing list