PLOT_TO_PS
PostScript Graphics Creation


PLOT_TO_PS is a FORTRAN90 program which reads a text file of plot commands and creates a PostScript file.

I often use this utility to make simple graphics illustrations.

Commands:

ARC X Y R ANGLE1 ANGLE2
draw the circular arc from ANGLE1 to ANGLE2, for a circle of radius R and center (X,Y).
ARROW X1 Y1 X2 Y2
draw an arrow from (X1,Y1) to (X2,Y2).
CIRCLE X Y R
draw a circle of radius R and center (X,Y).
CIRCLE_FILL X Y R
draw a circle of radius R and center (X,Y) and fill it with the current fill color.
DEBUG
switch the debugging state.
DRAWTO X Y
draw a line from the current point to (X,Y).
ELLIPSE X Y R1 R2 ANGLE
draw an ellipse centered at (X,Y) with axes lengths R1 and R2, an an angle ANGLE.
ELLIPSE_FILL X Y R1 R2 ANGLE
draw an ellipse centered at (X,Y) with axes lengths R1 and R2, an an angle ANGLE, and fill it with the current color.
ENDFILE
indicate the end of the file.
ENDPAGE
indicate the end of this "page" or image.
FILE NAME
specifies the name of the output file.
FILL_GRAY GRAY
sets the fill color to the given shade of gray.
FILL_RGB R G B
sets the fill color to the given RGB color.
FONT_SIZE H
sets the font size to the given height.
GRID X1 Y1 X2 Y2 N1 N2
draws an N1 by N2 grid in the box from (X1,Y1) to (X2,Y2).
HIST_FAT W
sets the width of histogram bars to W.
HISTOGRAM (followed by X,Y pairs, then END)
processes histogram data.
LABEL text
prints the text at the current position and current font size and current line color.
LABEL_SLANT ANGLE
sets a slant angle for a label.
LINE X1 Y1 X2 Y2
draws a line from (X1,Y1) to (X2,Y2).
LINE_GRAY GRAY
sets the line color to the given gray shade.
LINE_RGB R G B
sets the line color to the given RGB color.
LINE_WIDTH N
sets the line width. 1 is the finest.
LINETO X Y
draws a line from the current point to (X,Y). Same as DRAWTO.
MOVETO X Y
moves to (X,Y) without drawing.
PAGE
begins a new page or image.
POINT X Y
draws a point at (X,Y).
POINT_LIST (followed by X,Y pairs, then END)
draws a point at each of the (X,Y) pairs that follow.
POLYGON (followed by X,Y pairs, then END)
draws a outlined polygon by connecting the (X,Y) pairs that follow.
POLYGON_FILL (followed by X,Y pairs, then END)
draws a filled polygon by connecting the (X,Y) pairs that follow.
RADIUS X Y R ANGLE
for the circle of radius R and center (X,Y), draw the radial line at angle ANGLE.
SECTOR X Y R ANGLE1 ANGLE2
draws the sector of a circle centered at (X,Y) with radius R, from ANGLE1 to ANGLE2.
SECTOR_FILL X Y R ANGLE1 ANGLE2
draws the sector of a circle centered at (X,Y) with radius R, from ANGLE1 to ANGLE2, and fills it with current color.
SPACE X1 Y1 X2 Y2
defines the coordinate space to use in the current page.
SQUARE X Y R
draws a square centered at (X,Y) with radius R.
SQUARE_FILL X Y R
draws a square centered at (X,Y) with radius R and fills it.
STAR X Y R
draws a star centered at (X,Y) with radius R.
STAR_CIRCLE X Y R
draws open circles at the ten vertices of a star centered at (X,Y) with radius R.
STAR_DISK X Y R
draws filled disks at the ten vertices of a star centered at (X,Y) with radius R.
TRIANGLE X1 Y1 X2 Y2 X3 Y3
draws a triangle with the given vertices.
TRIANGLE_FILL X1 Y1 X2 Y2 X3 Y3
draws a triangle with the given vertices, and fills it with the current color.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

PLOT_TO_PS is available in a FORTRAN90 version

Related Data and Software:

GRF_TO_EPS, a FORTRAN90 program which converts a GRF file to EPS format;

POINTS_01_PLOT, a MATLAB program which reads an ASCII file containing points in the unit square, and makes an Encapsulated PostScript image;

PS_WRITE, a FORTRAN90 library which implements PostScript graphics routines that is used by PLOT_TO_PS.

TRIANGULATION_PLOT, a FORTRAN90 program which makes a PostScript image of a triangulation of points.

VECTOR_PLOT, a FORTRAN90 program which plots velocity fields and the velocity direction fields.

VORONOI_PLOT, a FORTRAN90 program which plots the Voronoi neighborhoods of points in the 2D unit square, using L1, L2 or LInfinity norms;

XY_DISPLAY, a MATLAB program which reads XY information defining points in 2D, and displays an image in a MATLAB graphics window;

XY_DISPLAY_OPENGL, a C++ program which reads XY information defining points in 2D, and displays an image using OpenGL.

XYL_DISPLAY, a MATLAB program which reads XYL information defining points and lines in 2D, and displays an image in a MATLAB graphics window.

XYL_DISPLAY_OPENGL, a C++ program which reads XYL information defining points and lines in 2D, and displays an image using OpenGL.

XYZ_DISPLAY, a MATLAB program which reads XYZ information defining points in 3D, and displays an image in the MATLAB graphics window.

XYZ_DISPLAY_OPENGL, a C++ program which reads XYZ information defining points in 3D, and displays an image using OpenGL.

Reference:

  1. Henry McGilton, Mary Campione,
    PostScript by Example,
    Addison-Wesley,
    ISBN: 0-201-63228-4

Source Code:

Examples and Tests:

Note that the program creates a PostScript file, but that, for display on this web page, we have used the ImageMagick program convert to convert them to PNG files.

123 is an attempt to make a plot of "1, 2, 3"

AREA_BASIS illustrates how the barycentric coordinates of a point in a triangle can be defined by the relative areas of subtriangles:

BILL_020 is a figure for page 20 of Bill's book, a plot of a typical linear basis function for a grid of triangular elements arranged in a hexagonal grid:

BILL_020_RECTANGLE is a version of BILL_020 in which the elements of interest are included in a rectangular grid.

BILL_055 is a figure for page 55 of Bill's book:

BILL_060 is a figure for page 60 of Bill's book:

BILL_061 is a figure for page 61 of Bill's book:

BURGERS_EQUATION is a 2D grid of points for a discretized Burgers equation, with red nodes for initial condition, green for boundaries, and gray for initially unknown:

CENTER_OF_MASS plots the center of mass of 6 weighted points:

CENTROID plots the centroid of 6 (equally weighted) points:

CHEBYSHEV illustrates the determination of the Chebyshev points.

CIRCLE is a plot of a circle:

CIRCLE* illustrates a continuation process for finding successive points on a circle.

CLIMB is an illustration for a trigonometry problem, without which, our students, upon hearing that a train climbed 1 mile up a slope, would draw a diagram in which the horizontal distance was 1 mile:

COMPONENTS_** illustrate the connected components algorithm.

CONVEX_COMBINATION illustrate two points can determine a line that is parameterized by combination coefficients that sum to 1. When the combination is "convex", the resulting point is between the two endpoints.

CONVEX_HULL illustrate the computation of the convex hull.

CRESCENT illustrates the construction of a crescent shape from two circles.

DIATOM fills in a region by plotting lots of points in it:

DOUBLE_CIRCLE is a plot of intersecting circles:

EGYPTIAN illustrates an odd fact about Egyptian mathematics:

FEM_MESH_1D illustrates the construction of nodes and elements for a 1D finite element mesh:

ELL illustrates the construction of nodes and elements for a 2D finite element mesh on an L-shaped region:

GRAPH_DIJKSTRA illustrates a graph used to demonstrate Dijkstra's shortest path algorithm.

GRAPH_DISCONNECTED illustrates a disconnected graph

GRAPH_MST illustrates a graph suitable for the minimum spanning tree problem, with 10 nodes and 17 links labeled with lengths.

GRAPH_MST2 illustrates a graph suitable for the minimum spanning tree problem, with 13 nodes and 21 links labeled with lengths.

GRAPH_MST_TREE illustrates one spanning tree for the GRAPH_MST graph.

GRAPH_MST_TREE_MINIMAL illustrates the minimal spanning tree for the GRAPH_MST graph.

GRAPH_PATHS is a graph on which we can ask the question of whether you can reach node A from node B.

GRAPH_SIMPLE illustrates a simple graph with 5 nodes and 4 links on a 3x3 bit of graph paper.

GRAPH_TSP illustrates a graph suitable for the minimum spanning tree problem or the traveling salesman problem, with 5 nodes and 10 links labeled with lengths.

GRID_CLIFF is a small finite element grid for Gene Cliff:

GRID_CLIFF2 illustrates how portions of the grid in GRID_CLIFF might be assigned to separate processors:

HEAT_EQUATION illustrates how a discretized version of the 1D time dependent heat equation might be set up and solved.

HISTOGRAM makes a histogram:

HORIZON illustrates the problem of determining the distance to the horizon:

HULL shows some points and their convex hull:

ICAM is a plan of the first floor of the Wright House.

LINE_DIST shows the computation of the distance of a point from a line.

LINE_PERP shows the projection value s for points perpendicular to a line.

LINE_POINTS shows how the formula p=p1+s*(p2-p1) defines a line.

MANHOLE illustrates the construction of a curve of constant width which is not a circle:

MAZE1 and MAZE2 illustrate a simple maze.

MUSEUM1 and MUSEUM2 illustrate the problem of visiting all the rooms in a museum.

POINT_LINE_ORIENTATION illustrates the problem of the relationship of a point to a line in 2D.

POINT_TRIANGLE_ORIENTATION illustrates the problem of the relationship of a point to a triangle in 2D.

POINTS is just some points on a grid:

POLYGON makes a outline cross:

POLYGON_FILL makes a gray-filled cross:

PRODUCT_GRIDS* shows a family of 2D product grids, for a talk on sparse grids.

PROTOTEIN was an example of a simplified model of a protein that can fold:

REFLECTOR is a plot used to illustrate the solution of a problem involving a "reflector". It illustrates the 'RADIUS' command:

SIXBYSIX_1 a 6 by six array of dots used to illustrate a talk involving a finite difference grid.

SIXBYSIX_2 a 6 by six array of dots used to illustrate a talk involving a finite difference grid.

SIXBYSIX_3 a 6 by six array of dots used to illustrate a talk involving a finite difference grid.

SIXBYSIX_4 a 6 by six array of dots used to illustrate a talk involving a finite difference grid.

SNAKE_POLYGON illustrates a polygon to be triangulated:

SPIRAL was an illustration of a spiral search on a grid:

SQUARE is a square, with a blue face, thick red lines, and dark gree vertices.

STAR is a plot of a star.

STOMACHION is a puzzle of Archimedes, involving 14 polygonal pieces that can be formed into a 12 by 12 square in 536 ways.

TANK is an illustration of the problem of determining the volume of a partially filled cylindrical tank:

TASKS1 shows how a sequential computer carries out 11 tasks, one at a time.

TASKS2 shows how an embarassingly parallel calculation looks.

TASKS3 shows how the tasks of Gauss elimination might look to a parallel computer.

TASKS4 shows how a task on a graph might look to a parallel computer.

TREES1 shows how 9 trees can make lots of lines of 3:

TREES2 shows how 16 trees can make lots of lines of 4:

TRIANGLE_CENTROID is a plot of a triangle which suggests how the centroid is computed.

TRIANGLE_DISTANCE illustrates the problem of determining the distance from a poiont to a (solid) triangle.

TRIANGLE_EXAMPLE1 is a plot of a triangle with the vertices labeled, used for an illustration in a discussion of triangles.

TRIANGLE_EXAMPLE2 is a plot of a triangle with the vertices labeled, used for an illustration in a discussion of triangles.

TRIANGLE_ORIENTATION shows how the sign of the three barycentric coordinates of a point determine the point's location relative to the triangle.

TRIANGULATION_01 is a triangulation which is not maximal because a node is unused.

TRIANGULATION_02 is a triangulation which is not maximal because a triangle is unused.

TRIANGULATION_03 is a triangulation which is maximal.

TRIANGULATION_04 is a triangulation which is not maximal because another line can be drawn, forming another triangle.

TSP_CROSSING illustrates how a portion of a proposed solution to the traveling salesman problem might exhibit a crossing.

TUTTE is the Tutte graph:

WEIGHT makes a line graph of someone's weight:

WORMS makes an illustration of some rectilinear worms on a grid:

List of Routines:

You can go up one level to the FORTRAN90 source codes.


Last revised on 28 October 2011.