Sunday, December 11, 2011

Axes of coordinates

This posts will talk about making axes. Axes is an essential part in a plotting. And after this posts, I think we have gained enough knowledge to take over the subject of plotting. So in the next posts plotting will be talked about.

The command for drawing axes in pstricks is "\psaxes(x0,y0)(x1,y1)(x2,y2)" in package "pst-plot" (so do remember to include this package). (x0,y0) is the position of the origin. (x1,y1) is the lower left corner of the coordinate and (x2,y2) is the upper right corner. If (x0,y0) is not specified, (x1,y1) will be used. And if both (x0,y0) and (x1,y1) is not specified, then the origin of the current coordinate will be used. It is to say that "\psaxes(x1,y1)(x2,y2)" is equivalent to "\psaxes(x1,y1)(x1,y1)(x2,y2)" and "\psaxes(x2,y2)" is equivalent to "\psaxes(0,0)(0,0)(x2,y2)". Isn't it very similar to the command "\psgrid"?

As axes is in fact a line, the command "\psaxes" can take almost all the parameters a line can take. And there are also some parameters specially for it.

"Ox(y)=num" is the label at origin with default value 0. "Dx(y)=num" is the label increment with default value 1. "dx(y)=num" is the distance between labels. If it takes value 0, Dx*\psunit will be used, and the default value is 0. "labels/ticks=all/x/y/none" controls which labels/ticks will appear. "showorigin=true/false" controls whether the origin label will be drawn. "tickstyle" can take values "full","top" and "bottom". If "top" is chosen, the ticks are only on the side of the axes away from the label. "Bottom" is just the opposite. And "full" gives ticks on both sides of the axes. The size of the ticks can be set using parameter "ticksize". Another mostly used parameter is "axesstyle", its legal values include "axes","frame" and "none".

In the following example the using of "\psaxes" is illustrated.

\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
  \begin{pspicture}(5,5)
    \psaxes[axesstyle=frame,Ox=0,Oy=100](4,4)
  \end{pspicture}
  \hspace{1.5cm}
  \begin{pspicture}(5,5)
    \psframe[linecolor=lightgray](0,0)(5,5)
    \psaxes[Dx=1,Dy=0.5,linewidth=1pt,
      ticksize=4pt]{->}(2,2)(0.5,0.5)(4.5,4.5)
  \end{pspicture}

  \vspace{1cm}

  \begin{pspicture}(5,5)
    \psframe[linecolor=lightgray](0,0)(5,5)
    \psgrid[gridcolor=red,subgridcolor=green,
      gridlabels=0](1,1)(1,1)(4,4)
    \psaxes[showorigin=false,
      tickstyle=bottom]{->}(1,1)(4.5,4.5)
  \end{pspicture}
  \hspace{1.5cm}
  \begin{pspicture}(5,5)
    \psframe[linecolor=lightgray](0,0)(5,5)
    \psaxes[axesstyle=frame,
      showorigin=false](5,5)(5,5)(1,1)
  \end{pspicture}
\end{document} 

Fig.1 The usage of Psaxes
Files Download: tex ps pdf

1 comment:

  1. Très intéressant et facile à comprendre mais une question comment faire une gille dans le dessin en haut à droit où l'échelle n'est pas la même sur les deux axes?
    merci

    ReplyDelete

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.