[pstricks] GetCoorinates Modification

Buddy Ledger buddyledger at gmail.com
Tue Apr 14 19:22:21 CEST 2009


Please help me.  I've modified one of the macro examples from the Latex
Graphics Companion (See below).  My objective was to specify the relative
error in the measurements via passing to the macro rather than from the
file.  This is for singular measurements where the equipment error is
estimated a priori.  Also I wanted to be able to plot data files in the form
(x y1 y2 y3 ... yn) much like the pstricks-add listplot function.

The code actually works for simply formatted data files example:
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7

Will plot fine with
GetCoordinates{\dataA}{relxerr}{relyerr}{plotno}{totalcol}.  However my data
files are formatted as such:
1.00E+001 2.00E+001 3.00E+001 4.00E+001
2.00E+001 3.00E+001 4.00E+001 5.00E+001
3.00E+001 4.00E+001 5.00E+001 6.00E+001
4.00E+001 5.00E+001 6.00E+001 7.00E+001

Listplot will handle this data file just fine but my macro gives a number
error on the character "E".  Now I assume I can do a conversion (text to
number) of the number at the GetCoordinates at ii level, but I don't know how.
I am no Tex/Latex/Postscript expert so my code may not be pretty.  An
suggestions for improvement would be appreciated.

Thanks,

Buddy Ledger

\documentclass[]{article}

        \usepackage{pst-all}
        \usepackage{pst-func}
        \usepackage{pst-eucl}
        \usepackage{pst-stru}
        \usepackage{pst-ob3d}
        \usepackage{pst-3dplot}
        \usepackage{pst-vue3d}
        \usepackage{pstricks-add}
        \usepackage{graphicx}
        \usepackage{ifthen}

\makeatletter

%\SpecialCoor
\def\pserrorLine{\pst at object{pserrorLine}}
\def\pserrorLine at i(#1)#2#3{\begingroup
 \use at par \pst at getcoor{#1}\pst at tempA
 \def\ps at xErr{#2}\def\ps at yErr{#3}%
 \psline{|-|}(! /yDot \pst at tempA exch pop \pst at number\psyunit div def
      /xDot \pst at tempA pop \pst at number\psxunit div def
      xDot yDot yDot \ps at yErr\space mul add )
     (! /yDot \pst at tempA exch pop \pst at number\psyunit div def
      /xDot \pst at tempA pop \pst at number\psxunit div def
      xDot yDot yDot \ps at yErr\space mul sub )
 \psline{|-|}(! /yDot \pst at tempA exch pop \pst at number\psyunit div def
      /xDot \pst at tempA pop \pst at number\psxunit div def
      xDot xDot \ps at xErr\space mul add yDot )
     (! /yDot \pst at tempA exch pop \pst at number\psyunit div def
      /xDot \pst at tempA pop \pst at number\psxunit div def
      xDot xDot \ps at xErr\space mul sub yDot )
\endgroup}

\def\GetCoordinates#1#2#3#4#5{%
\def\relxerr{#2}
\def\relyerr{#3}
\def\numplot{#4}
\def\numplotmax{#5}
\newcounter{loopcount}
\expandafter\GetCoordinates at i#1}

\def\GetCoordinates at i#1{\GetCoordinates at ii#1}
\def\GetCoordinates at ii D #1 {%
 \addtocounter{loopcount}{1}
 \ifthenelse{\value{loopcount}=1}{\def\plotxval{#1}}{%
 \ifthenelse{\value{loopcount}=\numplot}{\def\plotyval{#1}}{%
 \ifthenelse{\value{loopcount}=\numplotmax}{%
 \psdot(\plotxval,\plotyval)
 \pserrorLine(\plotxval,\plotyval){\relxerr}{\relyerr}%
 \setcounter{loopcount}{0}}{}}}
 \@ifnextchar D{\GetCoordinates at ii}{}}

\makeatother

\begin{document}
\pagestyle{empty}
\pagenumbering{arabic}

\psset{xAxisLabel=Centerline Velocity[m/s],
  yAxisLabel=Vibration Amplitude [\%Dia],
  xAxisLabelPos={c,-0.5in},
  yAxisLabelPos={-0.5in,c},
  lly=-0.55in,llx=-0.55in,ury=0.25in,urx=0.15in}

\readdata[ignoreLines=0]{\dataA}{data/doterrorbar.dat}

\begin{figure}
\centering
\begin{psgraph}[Dx=5,Dy=5,xsubticks=0,ysubticks=0](0,0)(0,0)(40,40){5.3in}{5.3in}

\GetCoordinates{\dataA}{0.01}{0.1}{2}{4}

\end{psgraph}
\caption{Error Bars.}
\end{figure}

\end{document}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20090414/2e7aa66a/attachment.html 


More information about the PSTricks mailing list