Chapter 2. Simple Use of PLplot

Table of Contents

Plotting a Simple Graph
Initializing PLplot
Defining Plot Scales and Axes
Labelling the Graph
Drawing the Graph
Drawing Points
Drawing Lines or Curves
Writing Text on a Graph
Area Fills
More Complex Graphs
Finishing Up
In Case of Error

Plotting a Simple Graph

We shall first consider plotting simple graphs showing the dependence of one variable upon another. Such a graph may be composed of several elements:

  • A box which defines the ranges of the variables, perhaps with axes and numeric labels along its edges.

  • A set of points or lines within the box showing the functional dependence.

  • A set of labels for the variables and a title for the graph.

In order to draw such a graph, it is necessary to call at least four of the PLplot functions:

  1. plinit, to initialize PLplot.

  2. plenv, to define the range and scale of the graph, and draw labels, axes, etc.

  3. One or more calls to plline or plpoin to draw lines or points as needed. Other more complex routines include plbin and plhist to draw histograms, plerrx and plerry to draw error-bars.

  4. plend, to close the plot.

More than one graph can be drawn on a single set of axes by making repeated calls to the routines listed in item 3 above. PLplot only needs to be initialized once unless plotting to multiple output devices.