next up previous contents index
Next: E.3 Fonts and different Up: E Sample Plots Previous: E.1 Basic graphics commands

E.2 Reading data from an external file

viewport 0.2 0.8 0.3 0.8   # Set the viewport.
data data.dat              # Open the data file.
xcolumn 1                  # Read the x data from column 1.
ycolumn 2                  # Read the y data from column 2.
pcolumn 3                  # Read the symbol data from column 3.
limits 0 10 0 20           # Set world coordinates.
box bcnst bcnst            # Draw a box.
xlabel (x)
ylabel (y)
mtext T 2 0.5 0.5 A Simple Graph
points                     # Draw symbol for each point.
connect                    # Connect the points.

Contents of the external file data.dat

  0.00   0.00  9.0
  0.20   0.04  2.5
  0.40   0.16  2.5
  0.60   0.36  2.5
  0.80   0.64  2.5
  1.00   1.00  9.0
  1.20   1.44  2.5
  1.40   1.96  2.5
  1.60   2.56  2.5
  1.80   3.24  2.5
  2.00   4.00  9.0
  2.20   4.84  2.5
  2.40   5.76  2.5
  2.60   6.76  2.5
  2.80   7.84  2.5
  3.00   9.00  9.0
  3.20  10.24  2.5
  3.40  11.56  2.5
  3.60  12.96  2.5
  3.80  14.44  2.5
  4.00  16.00  9.0
  4.20  17.64  2.5
  4.40  19.36  2.5
  4.60  21.16  2.5
  4.80  23.04  2.5
  5.00  25.00  9.0
  5.20  27.04  2.5
  5.40  29.16  2.5
  5.60  31.36  2.5
  5.80  33.64  2.5

 
Figure E.2: A plot using an external data file.



morgan@astro.umd.edu