[pstricks] Radian scale
Vince McGarry
vmcgarry at austin.rr.com
Wed Mar 9 05:58:31 CET 2005
I wrote the following crude switch which labeled either the x or y axis with
some common radian measures I needed. The code worked fine in all of test
files several weeks ago and I used it successfully to compile some graphs I
needed for a published document, but I attempted to use it this evening and
it failed. Perhaps there was something wrong with the original code I wrote.
I wrote it as a style file since it will be part of a larger style I'm
developing. Thanks for any help.
Vince
% pst-addmore.sty
\csname PSTAddMoreLoaded\endcsname
\let\PSTAddMoreLoaded\endinput
\ifx\PSTricksLoaded\endinput\else\input pstricks \fi
\ifx\PSTplotLoaded\endinput\else\input pst-plot \fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax
\pst at addfams{pst-addmore}
\def\RadianLabel#1{%
\ifnum#1=45 $\dfrac{\pi}{4}$ \else \ifnum#1=-45 $\dfrac{-\pi}{4}$
\else%
\ifnum#1=90 $\dfrac{\pi}{2}$ \else \ifnum#1=-90 $\dfrac{-\pi}{2}$
\else%
\ifnum#1=135 $\dfrac{3\pi}{4}$ \else \ifnum#1=-135
$\dfrac{-3\pi}{4}$ \else%
\ifnum#1=180 $\pi$ \else \ifnum#1=-180 $-\pi$ \else%
\ifnum#1=225 $\dfrac{5\pi}{4}$ \else \ifnum#1=-225
$\dfrac{-5\pi}{4}$ \else%
\ifnum#1=270 $\dfrac{3\pi}{2}$ \else \ifnum#1=-270
$\dfrac{-3\pi}{2}$ \else%
\ifnum#1=315 $\dfrac{7\pi}{4}$ \else \ifnum#1=-315
$\dfrac{-7\pi}{4}$ \else%
\ifnum#1=360 $2\pi$ \else \ifnum#1=-360 $-2\pi$ \else%
\ifnum#1=405 $\dfrac{9\pi}{4}$ \else \ifnum#1=-405
$\dfrac{-9\pi}{4}$ \else%
\ifnum#1=450 $\dfrac{5\pi}{2}$ \else \ifnum#1=-450
$\dfrac{-5\pi}{2}$ \else%
\ifnum#1=495 $\dfrac{11\pi}{4}$ \else \ifnum#1=-495
$\dfrac{-11\pi}{4}$ \else%
\ifnum#1=540 $3\pi$ \else \ifnum#1=-540 $-3\pi$ \else%
\ifnum#1=585 $\dfrac{13\pi}{4}$ \else \ifnum#1=-585
$\dfrac{-13\pi}{4}$ \else%
\ifnum#1=630 $\dfrac{7\pi}{2}$ \else \ifnum#1=-630
$\dfrac{-7\pi}{2}$ \else%
\ifnum#1=675 $\dfrac{15\pi}{4}$ \else \ifnum#1=-675
$\dfrac{-15\pi}{4}$ \else%
\ifnum#1=720 $4\pi$ \else \ifnum#1=-720 $-4\pi$ \else%
$#1$%
\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi%
}
\def\SetXTrigLabels{%
\ifpsXTrigLabels%
\renewcommand{\pshlabel}[1]{\footnotesize{\RadianLabel{##1}}}\else
\fi
}
\def\SetYTrigLabels{%
\ifpsYTrigLabels
\renewcommand{\psvlabel}[1]{\footnotesize{\RadianLabel{##1}}}
\fi
}
\newif\ifpsXTrigLabels \newif\ifpsYTrigLabels
\define at key[psset]{pst-addmore}{XTrigLabels}[true]{\@nameuse{psXTrigLabels#1
} \SetXTrigLabels}
\define at key[psset]{pst-addmore}{YTrigLabels}[true]{\@nameuse{psYTrigLabels#1
} \SetYTrigLabels}
\psset[pst-addmore]{XTrigLabels=false,YTrigLabels=false}
\catcode`\@=\PstAtCode\relax
%
\endinput
More information about the PSTricks
mailing list