Tuesday, December 13, 2011

How to plot using pstricks(1)----plot a function

After the previous posts, now we have the ability to deal with the plotting problems using pstricks. And this time we will talk about how to plot a function using pstricks.

The command used to plot a function in pstricks is "\psplot{xmin}{xmax}{function}". "xmin" and "xmax" determine the plot range and "function" is the function to be plotted. "function" should be written in postscript code. Since this blog is not about postscript, how to write a function in postscript code will not be talked in detail, only when it is used some simple explanation will be given.

There are also some optional parameters to control the appearance of the plot. "plotstyle=line,polygon,dots,curve..." controls the plotstyle, "plotpoints=int" controls how many points be plotted and other parameters such as "showpoints", "linestyle", "linecolor", "dotstyle"... have the same meaning as we have talked before.

Now we come to some examples.

      {0}{5}{x 2 exp 5 div} %(x^2)/5
      {0}{5}{x 2 exp 5 div} %(x^2)/5

Fig.1 An example of Psplot—Plot function y = x and y = x /5.

    \psset{xunit=0.0111cm} %xuni=4cm/360
      linecolor=blue]{0}{360}{x sin}
       %"x sin" is postscript code
       %with meaing sin(x)
      linestyle=dashed]{0}{360}{x cos}
       %"x cos" is postscript code
       %with meaing cos(x)
    \uput[-90](180,0){\scriptsize $\pi$}
    \uput[-90](360,0){\scriptsize $2\pi$}

Fig.2 Another example of Psplot—Plot function y = sin(x) and y =

Files Dowload: tex ps pdf

No comments:

Post a Comment

Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.