Friday, January 6, 2012

More options on pstricks plotting (1)

In package pst-plot there are only some basic options for a plot. To control the appearance of a plot more finely a new package called pstricks-add should be used.(In the new version of pst-plot, the options are greatly flourished, and you may also find these options in pst-plot.) In this package a great amount of new options have been introduced. In this posts only some of them will be covered, and to get a whole list of these options you may refer to the official document.

We know that by default the function of "\psplot" should be written in postscript code. And it is hard for a fresh man to understand the meaning of a long line postscript mathematical expression. With package "pstricks-add", you may get rid of the unfriendly postscript codes. Setting "algebraic=true", common algebraic notations can be used. For example you instead of using "x cos x 2 exp mul", you can write it "cos(x)*x^2".

To change the font size of the labels "labelFontSize" may be used. You can set "labelFontSize = \footnotesize", so that the font size of the labels will be smaller.

There are some options used to control the ticks and subticks. "subticks=num" set num subtics between two main ticks. "(x)(y)(sub)ticklinestyle", "(x)(y)(sub)tickcolor", "(x)(y)(sub)tickwidth", and "(x)(y)(sub)ticksize" control the linestyle, color, width and size of corresponding ticks.

There is an example on these options.

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pstricks-add}
\begin{document}
  \psset{yunit=0.2cm,xunit=0.5cm}
  \begin{pspicture}(-5,0)(5,25)
    \psaxes[linecolor=blue,axesstyle=frame,
      tickstyle=bottom,Dx=2,Dy=5,
      xsubticks=4,ysubticks=5,
      tickcolor=blue,subtickcolor=cyan,
      subticksize=0.5,ticksize=2mm,
      tickwidth=1.5pt,subtickwidth=0.75pt,
      ](-5,0)(5,25)
    \psset{algebraic=true}
    \psplot[linecolor=red]{-5}{5}{0.9*x^2}
  \end{pspicture}
\end{document} 

Fig.1 More options on Pstricks plotting
Files Download: tex ps pdf
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.