Thursday, December 1, 2011

Some basic graph objects in pstricks (2) ---- Lines

Command "\psline[parameters]{arrowstyle}(x1,y1)(x2,y2)...(xn,yn)" draws a line through points (x1,x2),(x2,y2)...(xn,yn).

Command "\pspolygon" is similar to "\psline", except that it draws a closed path and when a star is added, the closed area is filled with linecolor.

Arrowstyle can be specified to tell pstricks which type of arrowhead the line terminated. The most used parameters include "linecolor", "linewidth", "linestyle" "linearc" and "cornersize". Linecolor and linewidth have the its literal meanings. Linestyle can take values "none,solid,dashed,dotted". When "dashed" is used, paramter "dash=len1 len2" can be used to specify the dash pattern. And when "dotted" is used, paramete "dotsep=len" can be used to specify the distance between the nearest two dots. If you want the line have round corners, parameter "linearc" is very useful. This parameter specifies the radius of arcs drawn at the corners. To show the points on the line, "showpoints=true" can be useful. To show how these commands and parameters are used, there is an example.

\documentclass{article}
\usepackage{pstricks}
\begin{document}
  \begin{pspicture}(5,5)
    \pspolygon(0,0)(5,0)(5,5)(0,5)
    \pspolygon*[linestyle=none,linecolor=blue,
      linearc=4pt](0,0)(1,0)(1,1)(0,1)
    \psline[linecolor=red,linestyle=solid]
      {<->}(1,1) (4,4)
    \psline[linewidth=5pt,linestyle=dashed,
      dash=3pt 3pt]{->}(1,4) (4,1)
    \psline[showpoints=true]
      (0,0)(1,5)(2,0)(3,5)(4,0)(5,5)
    \psline[linearc=5pt,linecolor=green]
      (0,5)(1,0)(2,5)(3,0)(4,5)(5,0)
  \end{pspicture}
\end{document}

The lines looks like this:
Fig.1 Lines drawn using Pstricks
Files Download: tex ps pdf


1 comment:

  1. Very nice illustration of the use of \pspolygon[par], parameters.


    Thank you,

    -peter rejto

    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.