[pstricks] - plotstyle=line versus curve in pscustom

Hensh, Richard hensh at math.msu.edu
Mon Oct 24 16:55:24 CEST 2011


I did it this way so that I could easily graph a function and its inverse as quickly as possible. As you can see, your code suggestion works much better than mine. 

thanks
rick

\documentclass[dvips]{minimal}
\usepackage{pst-func}
\usepackage{pstricks}
%\input{rjh-local.tex}
\newpsobject{myplot}{psplot}{%
    ,plotstyle=curve%
    ,plotpoints=200}
\definecolor{DarkGreen}{rgb}{0.233,0.545,0.133}%
\begin{document}

\def\xmin{-5}\def\xmax{20}
\def\ymin{-5}\def\ymax{20}
\def\dommin{0}\def\dommax{\xmax}
\psset{unit=4mm,plotpoints=200}
\pstVerb{%
    /f at x {dup 2 mul exch 1 atan Pi mul 180 div mul} def %
    /y0 {4 Pi mul 3 div} def %
    /x0 {3 sqrt} def %
    /L at x {x0 sub 2 Pi mul mul x0 div y0 add} def %
  }
  \begin{center}
  \begin{pspicture}(\xmin,\ymin)(\xmax,\ymax)
  %\showgrid
  \psaxes[ticks=none,labels=none,linewidth=1pt,linecolor=gray,arrows=->,arrowscale=1.5](0,0)(\xmin,\ymin)(\xmax,\ymax)
  \psclip{\psframe[linestyle=none](\xmin,\ymin)(\xmax,\ymax)}
    \myplot[linecolor=gray,linewidth=1.0pt,linestyle=dashed]{\xmin}{\xmax}{x}%
    %%Function f(x)
    \rput(!0 x0){\psCumIntegral[linecolor=blue,linewidth=2.0pt]{0}{\xmax}{f at x}}      \myplot[linecolor=gray,linewidth=1.0pt]{\xmin}{\xmax}{x L at x}%
    %%Inverse function, f^{-1}(x)
    {%
    \psset{swapaxes=true}
    \rput(!x0 0){\psCumIntegral[linecolor=DarkGreen,linewidth=2.0pt]{0}{\xmax}{f at x}}%
    \myplot[linecolor=gray,linewidth=1.0pt]{\xmin}{\xmax}{x L at x}%
    }%
  \endpsclip
  \SpecialCoor%
  \pnode(!x0 y0){A}
  \pnode(!y0 x0){B}
  \psdots[linecolor=red,dotscale=1.125](A)(B)
  {\psset{arrows=->,arrowscale=1.5}%
  \psline(8,5)(B)
  \psline(5,10)(A)
  }%
  \uput{3pt}[40](8,5){{$(4\pi/3,\sqrt{3})$}}
  \uput{3pt}[60](5,10){{$(\sqrt{3},4\pi/3)$}}
  \uput{6pt}[-80](15,3){{$y=f^{-1}(x)$}}
  \uput{6pt}[0](-1,15){{$y=f(x)$}}
  \NormalCoor
  \end{pspicture}
  \[ f(x) = \sqrt{3}+\int_0^x 2t\tan^{-1}t\, dt \]
  \end{center}
\end{document}


________________________________________
From: pstricks-bounces at tug.org [pstricks-bounces at tug.org] on behalf of Christoph Bersch [usenet at bersch.net]
Sent: Monday, October 24, 2011 4:08 AM
To: pstricks at tug.org
Subject: Re: [pstricks] - plotstyle=line versus curve in pscustom

Hi Richard,

On 24.10.2011 00:42, Hensh, Richard wrote:
> \psclip{\psframe[linestyle=none](\xmin,\ymin)(\xmax,\ymax)}
>      \myplot[linecolor=gray,linewidth=1.0pt,linestyle=dashed]{\xmin}{\xmax}{x}%
>      \pscustom[plotpoints=200,linecolor=gray,linewidth=0.0pt]{%
>        \translate(!0 x0)%
>        \psCumIntegral{0}{\xmax}{f at x}%
>        \stroke[linecolor=blue,linewidth=2.0pt]
>        %\newpath
>        \translate(!0 x0 neg)%
>        \myplot{\xmin}{\xmax}{x L at x}%
>        \stroke[linecolor=gray,linewidth=1.0pt]
>      }
>    \endpsclip

Why do you use \pscustom, to draw two distinct functions? The purpose of
\pscustom is to join different segments to a _single_ path, therefore
also the linewidth and linecolor settings of \psplot etc. are ignored
(which you "fix" by using \stroke).

Just use the following:

\psclip{\psframe[linestyle=none](\xmin,\ymin)(\xmax,\ymax)}
   \myplot[linecolor=gray,linewidth=1.0pt,linestyle=dashed]%
       {\xmin}{\xmax}{x}%
   \rput(!0 x0){%
       \psCumIntegral[linecolor=blue,linewidth=2.0pt,plotpoints=200]%
           {0}{\xmax}{f at x}%
   }%
   \myplot[linecolor=gray,linewidth=1.0pt]{\xmin}{\xmax}{x L at x}%
\endpsclip

You can also replace \myplot by \psline

Christoph
_______________________________________________
PSTricks mailing list
PSTricks at tug.org
http://tug.org/mailman/listinfo/pstricks
archive: http://www.tug.org/pipermail/pstricks/


More information about the PSTricks mailing list