The primitive routines can be used in any combination and order after the viewport and window have been defined. They all indicate where the primitive is to appear on the view surface by specifying world coordinates. See the subroutine descriptions in Appendix A for more details.

`PGLINE`

.
This draws
one or more connected straight-line segments (generally called a
`N`

) of points defining the polyline, and two
arrays (`XPTS`

and `YPTS`

) containing the world
CALL PGLINE (N, XPTS, YPTS)The two routines

`PGMOVE`

and `PGDRAW`

are even more
primitive than `PGLINE`

, in the sense that any line graph
can be produced by calling these two routines alone. In general,
`PGLINE`

should be preferred, as it is more
modular. `PGMOVE`

and `PGDRAW`

are provided for
those who are used to Calcomp-style plotting packages.
`PGMOVE`

moves the plotter ``pen'' to a specified point,
without drawing a line (``pen up''). It has two arguments: the
world-coordinates of the required new pen position.
`PGDRAW`

moves the plotter ``pen'' from its current
position (defined by the last call of `PGMOVE`

or
`PGDRAW`

) to a new point, drawing a straight line as it
goes (``pen down''). The above call to `PGLINE`

could be
replaced by the following:
CALL PGMOVE (XPTS(1), YPTS(1)) DO I=2,N CALL PGDRAW (XPTS(I), YPTS(I)) END DO

`PGPT`

draws one or
more graph markers (sometimes called a `N`

) of points to mark, two
arrays (`XPTS`

and `YPTS`

) containing the world
`NSYM`

) identifying the symbol to use:
CALL PGPT (N, XPTS, YPTS, NSYM)The symbol number can be: -1, to draw a dot of the smallest possible size (one pixel); 0--31, to draw any one of the symbols in Figure 4.1; -3 - -8, to draw regular polygon with 3--8 sides; 33--127, to draw the corresponding ASCII character (the character is taken from the currently selected text font); or >127, to draw one of the Hershey symbols from Appendix B. The Fortran

`ICHAR`

function can be used to obtain the ASCII value;
e.g., to use letter CALL PGPT (1, 0.5, 0.75, ICHAR('F') )

`PGTEXT`

, which writes a
horizontal character string starting at a specific CALL PGTEXT (X, Y, 'A text string')

`PGTEXT`

is actually a simplified interface to the more
general primitive routine `PGPTXT`

, which allows one to
change orientation and justification of the text, e.g.,
CALL PGPTXT (X, Y, 45.0, 0.5, 'A text string')writes the text at an angle of 45 degrees to the horizontal, centered at

Both `PGTEXT`

and `PGPTXT`

require the position
of the text string to be specified in world coordinates. When
annotating a graph, it is usually more convenient to position the text
relative to the edge of the viewport, rather than in world-coordinate
space. The routine `PGMTXT`

is provided for this,
and `PGLAB`

provides a
simple interface to `PGMTXT`

for the normal job of
annotating an *(x,y)* graph.

The appearance of text can be altered by specifying a number of
*attributes*, described in the next chapter. In particular, the
character size and character font can be changed. Figure
4.2 illustrates some of the possibilities.

To include one of the graph marker symbols (0--32) in a text string, use the
Fortran `CHAR`

function, e.g.,

CALL PGTEXT (X, Y, 'Points marked with '//CHAR(17))

`PGPTXT`

(and all the PGPLOT routines which
call it, e.g., `PGTEXT`

, `PGLAB`

) allows one to
include `\`

). The following escape sequences are defined (the
letter following the `\`

may be either upper or lower
case):

\u | start a superscript, or end a subscript |

\d | start a subscript, or end a superscript (note that \u and \d must always be used in pairs) |

\b | backspace (i.e., do not advance text pointer after plotting the previous character) |

\fn | switch to Normal font (1) |

\fr | switch to Roman font (2) |

\fi | switch to Italic font (3) |

\fs | switch to Script font (4) |

\\ | backslash character (\) |

\x | multiplication sign (×) |

\. | centered dot (·) |

\A | ångström symbol (Å) |

\gx |
greek letter corresponding to roman letter x,
as indicated in Figure 4.3 |

\mn\m nn |
graph marker number n or nn (1-31),
as indicated in Figure 4.1 |

\(nnnn) |
character number nnnn (1 to 4 decimal digits) from the Hershey character set;
the closing parenthesis may be omitted if the next character is neither
a digit nor ``)''. This makes a number of special characters (e.g.,
mathematical, musical, astronomical, and cartographical symbols)
available. See Appendix B for a list of available characters. |

The routine `PGPOLY`

is used to fill an area defined as a polygon. It has three arguments:
the number (`N`

) of vertices defining the polygon, and two
arrays (`XPTS`

and `YPTS`

) containing the world
*x* and *y*-coordinates of the vertices:

CALL PGPOLY (N, XPTS, YPTS)If the polygon is not convex, it may not be obvious which points in the image are inside the polygon. PGPLOT assumes that a point is inside the polygon if a straight line drawn from the point to infinity intersects an odd number of the polygon's edges.

For the special case of a *rectangle* with edges parallel to the
coordinate axes, it is better to use routine `PGRECT`

instead of
`PGPOLY`

; this routine will use the hardware rectangle-fill
capability if available. `PGRECT`

has four arguments: the
*(x,y)* world coordinates of two opposite corners (note the order
of the arguments):

CALL PGRECT (X1, X2, Y1, Y2)To draw a

`PGIRC`

. This routine has
three arguments: the CALL PGCIRC (X, Y, RADIUS)

Next: Chapter 5

PGPLOT

Tim Pearson, California Institute of Technology,

Copyright © 1995 California Institute of Technology