LaTeX pictures: best way to typeset graphs

Denis Girou Denis.Girou at idris.fr
Wed Nov 3 20:41:06 CET 1999


-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------

The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "Neil.Zanella" == Neil Zanella <nzanella at tulip.math.ualberta.ca> writes:

    Neil.Zanella> OK, I looked at PSTricks and friends but it did not seem like
    Neil.Zanella> any of them could do exactly what I wanted although PSTricks
    Neil.Zanella> seemed to be able to do almost what I was looking for.
    Neil.Zanella> As a simple example, is there a simple way to typeset the following
    Neil.Zanella> picture with pstricks? What is the easiest (right) way to do this?
    Neil.Zanella> I can do it with eepic but it takes a while to compute the points.
    Neil.Zanella> What takes the longest is placing all the labels.

    Neil.Zanella>                       ^ x
    Neil.Zanella>                       |
    Neil.Zanella>                       |
    Neil.Zanella>                     1 -            1
    Neil.Zanella>                       |     f(x) = - sin(x)
    Neil.Zanella>                       |            2
    Neil.Zanella>                   1/2 -  xxxxx
    Neil.Zanella>                       | x     xx
    Neil.Zanella>                       |x        x 
    Neil.Zanella>   --|-----|-----|-----------|-----|-----|-----|-----|----->
    Neil.Zanella>                       |    Pi/2   Pi   3Pi/2  2Pi         y
    Neil.Zanella>                       |            x        x
    Neil.Zanella>                   1/2 -             x     xx
    Neil.Zanella>                       |              xxxxx
    Neil.Zanella>                       |                
    Neil.Zanella>                     1 -
    Neil.Zanella>                       |

    Neil.Zanella> If it can do this in a simple way than it can do pretty much everything
    Neil.Zanella> I was looking for.

  As people already tell you, there are a lot of packages to do such kind of
graphs. Here is a solution with PSTricks (the only not obvious part for
beginners is probably the way to have automatically graduations printed as
multiples of Pi).


\documentclass{article}

\usepackage{pstcol} % To use the standard "color" package with PSTricks
\usepackage{pst-plot}

\pagestyle{empty}

\begin{document}

\psset{yunit=3}

\psframebox[framesep=0]{%
\begin{pspicture}(-1.1,-1.1)(7,1.4)
  \psaxes[Dx=1.5708,Dy=0.5,labels=y]{->}(0,0)(0,-1.1)(7,1.1) % Pi/2 = 1.5708
  \rput(1.5708,-0.15){$\frac{\Pi}{2}$}
  \rput(3.1416,-0.15){$\Pi$}
  \rput(4.7124,-0.15){$\frac{3 \Pi}{2}$}
  \rput(6.2832,-0.15){$2 \Pi$}
  \rput(3,1.3){\Large Sinus curve}
  \rput(6.8,-0.1){$y$}
  \rput(-0.3,1.15){$x$}
  \rput[r](7,0.8){\textcolor{red}{$f(x) = \frac{1}{2} \sin (x)$}}
  % 1 radian = 57.2958 degrees
  \psplot[linecolor=red]{0}{6.2832}{x 57.2958 mul sin 0.5 mul} % sin(x) / 2 
\end{pspicture}}

\vfill

\psframebox[framesep=0]{%
\begin{pspicture}(-1.1,-1.1)(13,1.4)
  \psaxes[Dx=1.5708,Dy=0.5,labels=y]{->}(0,0)(0,-1.1)(13,1.1) % Pi/2 = 1.5708
  \rput(1.5708,-0.15){$\frac{\Pi}{2}$}
  \rput(3.1416,-0.15){$\Pi$}
  \multido{\Npos=4.7124+3.1416,\Icoef=3+1}{3}{%
    \rput(\Npos,-0.15){$\frac{\Icoef \Pi}{2}$}}
  \multido{\Npos=6.2832+3.1416,\Icoef=2+1}{3}{%
    \rput(\Npos,-0.15){$\Icoef \Pi$}}
  \rput(7,1.3){\Large Sinus curve}
  \rput(12.8,0.1){$y$}
  \rput(-0.3,1.15){$x$}
  \rput(7,0.8){\textcolor{cyan}{$f(x) = \frac{1}{2} \sin (x)$}}
  \psplot[linecolor=cyan]{0}{12.5664}{x 57.2958 mul sin 0.5 mul} % sin(x) / 2 
\end{pspicture}}

\end{document}

Denis Girou
-- 
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------

-----------------------------------------------------------------------------
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