[pst-plot] Polar plots

Denis Girou Denis.Girou at idris.fr
Thu Jun 11 19:22:57 CEST 1998


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

  Ulrich Dirr <udirr at das-team.com> give me the suggestion to allow polar plots 
with the `pst-plot' package. In fact, it is very easy to implement.
I do it as an extension of the \psplot macro, just defining a new "polarplot"
parameter.

  The solution and the examples are from Ulrich; I just integrated properly
in the source code.

  Thanks for this good idea!

D.G.

\documentclass{article}

\usepackage{pst-plot}

\makeatletter

% D.G. addition - Jun.  9, 1998 - Polar plots using the \psplot macro
% Code added according the way suggested by Ulrich Dirr <udirr at das-team.com>

% For polar plots
\newif\ifpolarplot
\def\psset at polarplot#1{\@nameuse{polarplot#1}}
\psset at polarplot{false}

\def\psplot at i#1#2#3{%
  \pst at killglue
  \begingroup
    \use at par
    \@nameuse{beginplot@\psplotstyle}%
% D.G. modification begin - Jun.  9, 1998
    \ifpolarplot
      \addto at pscode{%
        \psplot at init
        /x #1 def
        /x1 #2 def
        /dx x1 x sub \psk at plotpoints div def
        /xy {% Adapted from \parametricplot at i
          #3 dup x cos mul exch x sin mul
          \pst at number\psxunit mul exch
          \pst at number\psyunit mul exch
        } def}%
    \else
% D.G. modification end
      \addto at pscode{%
        \psplot at init
        /x #1 def
        /x1 #2 def
        /dx x1 x sub \psk at plotpoints div def
        /xy {
          x \pst at number\psxunit mul
          #3 \pst at number\psyunit mul
        } def}%
% D.G. modification begin - Jun.  9, 1998
    \fi
% D.G. modification end
    \gdef\psplot at init{}%
    \@pstfalse
    \@nameuse{testqp@\psplotstyle}%
    \if at pst
      \psplot at ii
    \else
      \psplot at iii
    \fi
  \endgroup
  \ignorespaces}

\makeatother

\pagestyle{empty}

\begin{document}

% Examples from Ulrich Dirr <udirr at das-team.com>

\footnotesize

\psset{plotpoints=200}

\begin{pspicture}*(-5,-5)(3,3)
  \psaxes[labelsep=.75mm,arrowlength=1.75,ticksize=2pt,linewidth=0.17mm]%
         {->}(0,0)(-4.99,-4.99)(3,3)
  \rput[Br](3,-.35){$x$}
  \rput[tr](-.15,3){$y$}
  \rput[Br](-.15,-.35){$0$}
  %
  \psset{linewidth=.35mm,polarplot=true}
  \psplot{140}{310}{3 neg x sin mul x cos mul x sin 3 exp x cos 3 exp add div}
  \psplot{140}{310}{6 neg x sin mul x cos mul x sin 3 exp x cos 3 exp add div}
  \psplot{140}{310}{9 neg x sin mul x cos mul x sin 3 exp x cos 3 exp add div}
\end{pspicture}
\hfill
\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
  \psaxes[labelsep=.75mm,arrowlength=1.75,ticksize=2pt,linewidth=0.17mm]%
         {->}(0,0)(-2.5,-2.5)(2.5,2.5)
  \rput[Br](2.5,-.35){$x$}
  \rput[tr](-.15,2.5){$y$}
  \rput[Br](-.15,-.35){$0$}
  %
  \psset{linewidth=.35mm,plotstyle=curve,polarplot=true}
  \psplot{0}{360}{x cos 2 mul x sin mul}
  \psplot{0}{360}{x cos 3 mul x sin mul}
  \psplot{0}{360}{x cos 4 mul x sin mul}
\end{pspicture}

\vspace{1cm}
\psset{unit=0.5}
\begin{pspicture}(-8.5,-8.5)(9,9)
  \psaxes[Dx=2,dx=2,Dy=2,dy=2,labelsep=.75mm,arrowlength=1.75,ticksize=2pt,
          linewidth=0.17mm]{->}(0,0)(-8.5,-8.5)(9,9)
  \rput[Br](9,-.7){$x$}
  \rput[tr](-.3,9){$y$}
  \rput[Br](-.3,-.7){$0$}
  %
  \psset{linewidth=.35mm,plotstyle=curve,polarplot=true}
  \psplot{0}{720}{8 2.5 x mul sin mul}
\end{pspicture}

\end{document}

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list