[pstricks] Using Symbol postscript font in \addto at pscode

Buddy Ledger buddyledger at gmail.com
Thu Apr 23 05:00:07 CEST 2009


Sorry I didn't include all the code the first time.

Thanks in advance.
Buddy

\documentclass[]{article}

\usepackage{pst-all}
\usepackage{pst-func}
\usepackage{pstricks-add}
\usepackage{filecontents}

\begin{filecontents*}{datafile.dat}
Vc CH1DiaMT3 CH2DiaMS3 CH3DiaMT6 CH4DiaMS6
1.600000E+000 9.826193E+000 6.984904E+000 8.066498E+000 4.960284E+000
1.800000E+001 1.163769E+001 9.443092E+000 1.030773E+001 5.544281E+000
2.800000E+001 1.590967E+001 1.898143E+001 1.214513E+001 5.621518E+000
\end{filecontents*}

\makeatletter
\define at key[psset]{pst-func}{yShift}[0]{\def\psk at yShift{#1}}
\define at key[psset]{pst-func}{xyPlotLabels}[0]{\def\psk at xyPlotLabels{#1}}
\psset[pst-func]{yShift=0}
\psset[pst-func]{xyPlotLabels=0}
\def\psPrintCoor{\pst at object{psPrintCoor}}
\def\psPrintCoor at i(#1)#2#3{%
   \ifnum\psk at xyPlotLabels=1
   \begin at SpecialObj
   \use at par \pst at getcoor{#1}\pst at tempA
   \addto at pscode{
      /mfont {\psk at PSfont findfont \psk at fontscale scalefont setfont} 
bind def
      /s1 {/Symbol findfont \psk at fontscale scalefont setfont} bind def
      \pst at tempA pop \pst at number\psyunit div \psk at decimals -1 gt
      { 10   \psk at decimals exp dup 3 1 roll mul cvi exch div } if
      \psk at valuewidth string cvs /xcoor exch def
%
      #2 \pst at tempA pop \pst at number\psyunit div mul \psk at decimals -1 gt
      { 10   \psk at decimals exp dup 3 1 roll mul cvi exch div } if
      \psk at valuewidth string cvs /delx exch def
%
      \pst at tempA exch pop \pst at number\psyunit div \psk at decimals -1 gt
      { 10  \psk at decimals exp dup 3 1 roll mul cvi exch div } if
      \psk at valuewidth string cvs /ycoor exch def % save output
%
      #3 \pst at tempA exch pop \pst at number\psyunit div mul \psk at decimals 
-1 gt
      { 10   \psk at decimals exp dup 3 1 roll mul cvi exch div } if
      \psk at valuewidth string cvs /dely exch def
%
      \ifPst at comma        % do we have to change dot to comma
        0 1 xcoor length 1 sub {
          /Index exch def
          xcoor Index get 46 eq { xcoor Index 44 put } if
        } for
      \fi
      \ifPst at comma        % do we have to change dot to comma
        0 1 delx length 1 sub {
          /Index exch def
          delx Index get 46 eq { delx Index 44 put } if
        } for
      \fi
      \ifPst at comma        % do we have to change dot to comma
        0 1 ycoor length 1 sub {
          /Index exch def
          ycoor Index get 46 eq { ycoor Index 44 put } if
        } for
      \fi
      \ifPst at comma        % do we have to change dot to comma
        0 1 dely length 1 sub {
          /Index exch def
          dely Index get 46 eq { dely Index 44 put } if
        } for
      \fi
      newpath
      \psk at xShift\space \psk at yShift\space moveto s1 ([) show  %I want ( 
not [
      2 0 rmoveto mfont xcoor show
      #2 \pst at tempA pop \pst at number\psyunit div mul 0 ne {
      2 0 rmoveto s1 (+/-) show        %I want +- character Symbol \261
      2 0 rmoveto mfont delx show} if
      2 0 rmoveto s1 (,) show
      2 0 rmoveto mfont ycoor show
      #3 \pst at tempA exch pop \pst at number\psyunit div mul 0 ne {
      2 0 rmoveto s1 (+/-) show        %I want +- character Symbol \261
      2 0 rmoveto mfont dely show} if
      2 0 rmoveto s1 (]) show   %I want ) not ] Symbol \051 gives 
undefined error
   }%
   \end at SpecialObj%
   \fi
}
\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}
  \if\ps at yErr 0\relax \else
  \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 )
  \fi
  \if\ps at xErr 0\relax \else
  \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 )
   \fi
\endgroup}

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

\def\GetCoordinates at i#1{\GetCoordinates at ii#1}
\def\GetCoordinates at ii D #1 {%
  \stepcounter{loopcount}
  \ifnum\theloopcount=1 \def\plotxval{#1 }\else
     \ifnum\theloopcount=\numplot \def\plotyval{#1 }\else
       \ifnum\theloopcount=\numplotmax
         \psdot(!\plotxval \plotyval)
         \pserrorLine(!\plotxval \plotyval){\relxerr}{\relyerr}
         \uput{0}[0](!\plotxval \plotyval){% Data Labels Preliminary
          \psPrintCoor(!\plotxval \plotyval){\relxerr}{\relyerr}}
         \setcounter{loopcount}{0}
       \fi\fi\fi%
  \@ifnextchar D{\GetCoordinates at ii}{}}
\makeatother

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

\psset{xAxisLabel=Centerline Velocity[m/s], %Setup for psgraph env
		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=1]{\dataA}{datafile.dat}

\psset{dotstyle=square*,arrows=|-|} %Setup errorbar & dot style
\psset[pst-func]{xShift=10,yShift=10,decimals=1,xyPlotLabels=1}

\begin{figure}
\centering
\begin{psgraph}[Dx=5,Dy=5,xsubticks=5,ysubticks=5,axesstyle=frame]%
(0,0)(0,0)(40,40){4.5in}{4.5in}
\GetCoordinates{\dataA}{0.1}{0.1}{2}{5}
\end{psgraph}
\caption{Error Bars.}
\end{figure}
\end{document}




More information about the PSTricks mailing list