PLplot-5 3 1
PLplot-5 3 1
Maurice J. LeBrun
Geoff Furnish
University of Texas at Austin
Institute for Fusion Studies
Table of Contents
I. Introduction .................................................................................................................. xi
1. Introduction ............................................................................................................................... 1
The PLplot Plotting Library ................................................................................................. 1
Getting a Copy of the PLplot Package.................................................................................. 2
Installing and Using the PLplot Library ............................................................................... 2
Organization of this Manual.................................................................................................. 2
Copyrights ............................................................................................................................. 3
Additional Copyrights................................................................................................... 3
Credits................................................................................................................................... 4
II. Programming ................................................................................................................ 1
2. Simple Use of PLplot ................................................................................................................. 3
Plotting a Simple Graph ....................................................................................................... 3
Initializing PLplot ................................................................................................................. 3
Defining Plot Scales and Axes............................................................................................... 3
Labeling the Graph ............................................................................................................... 4
Drawing the Graph................................................................................................................ 5
Drawing Points ............................................................................................................. 5
Drawing Lines or Curves .............................................................................................. 5
Writing Text on a Graph .............................................................................................. 6
Area Fills ...................................................................................................................... 6
More Complex Graphs.................................................................................................. 7
Finishing Up.......................................................................................................................... 7
In Case of Error..................................................................................................................... 7
3. Advanced Use of PLplot ............................................................................................................ 9
Command Line Arguments.................................................................................................... 9
Output Devices...................................................................................................................... 9
Driver Functions ......................................................................................................... 11
PLplot Metafiles and Plrender.................................................................................... 11
Family File Output ..................................................................................................... 14
Interactive Output Devices ......................................................................................... 15
Specifying the Output Device..................................................................................... 15
Adding FreeType Library Support to Bitmap Drivers ........................................................ 17
Write a call back function to plot a single pixel ......................................................... 17
Initialise FreeType ...................................................................................................... 17
Add Function Prototypes............................................................................................ 19
Add Closing functions................................................................................................. 19
View Surfaces, (Sub-)Pages, Viewports and Windows ........................................................ 20
Defining the Viewport ................................................................................................ 20
Defining the Window .................................................................................................. 21
Annotating the Viewport............................................................................................ 22
Setting up a Standard Window .................................................................................. 22
Setting Line Attributes........................................................................................................ 23
Setting the Area Fill Pattern .............................................................................................. 23
Setting Color ....................................................................................................................... 24
Color Map0 ................................................................................................................. 24
Color Map1 ................................................................................................................. 24
Setting Character and Symbol Attributes ........................................................................... 27
Escape Sequences in Text.................................................................................................... 28
Three Dimensional Surface Plots ........................................................................................ 29
iii
iv
IV. Reference................................................................................................................... 75
15. Bibliography ........................................................................................................................... 77
References............................................................................................................................ 77
16. The Common API for PLplot ................................................................................................ 79
pl_setcontlabelformat: Set format of numerical label for contours .................................... 79
pl_setcontlabelparam: Set parameters of contour labelling other than format of numerical
label ............................................................................................................................ 79
pladv: Advance the (sub-)page ............................................................................................ 79
plaxes: Draw a box with axes, etc. with arbitrary origin.................................................... 80
plbin: Plot a histogram from binned data........................................................................... 81
plbop: Begin a new page...................................................................................................... 82
plbox: Draw a box with axes, etc ........................................................................................ 82
plbox3: Draw a box with axes, etc, in 3-d ........................................................................... 83
plcalc_world: Calculate world coordinates and corresponding window index from relative
device coordinates....................................................................................................... 85
plclear: Clear current (sub)page......................................................................................... 85
plclr: Eject current page .................................................................................................... 86
plcol: Set color.................................................................................................................... 86
plcol0: Set color, map0 ....................................................................................................... 86
plcol1: Set color, map1 ....................................................................................................... 87
plcont: Contour plot ........................................................................................................... 87
plcpstrm: Copy state parameters from the reference stream to the current stream ............ 88
plend: End plotting session.................................................................................................. 88
plend1: End plotting session for current stream .................................................................. 88
plenv0: Same as plenv but if in multiplot mode does not advance the subpage, instead clears
it. ................................................................................................................................ 88
plenv: Set up standard window and draw box .................................................................... 90
pleop: Eject current page .................................................................................................... 91
plerrx: Draw x error bar ..................................................................................................... 91
plerry: Draw y error bar ..................................................................................................... 92
plfamadv: Advance to the next family file on the next new page......................................... 92
plfill: Draw filled polygon ................................................................................................. 92
plfill3: Draw filled polygon in 3D ..................................................................................... 93
plflush: Flushes the output stream .................................................................................... 93
plfont: Set character font.................................................................................................... 93
plfontld: Load character font ............................................................................................. 94
plgchr: Get character default height and current (scaled) height ....................................... 94
plgcol0: Returns 8-bit RGB values for given color from color map0 .................................. 94
plgcolbg: Returns the background color (cmap0[0]) by 8-bit RGB value ........................... 95
plgcompression: Get the current device-compression setting............................................... 95
plgdev: Get the current device (keyword) name.................................................................. 95
plgdidev: Get parameters that define current device-space window.................................... 95
plgdiori: Get plot orientation ............................................................................................. 96
plgdiplt: Get parameters that define current plot-space window ....................................... 96
plgfam: Get family file parameters....................................................................................... 97
plgfnam: Get output file name ............................................................................................. 97
plglevel: Get the (current) run level .................................................................................. 97
plgpage: Get page parameters ............................................................................................. 98
plgra: Switch to graphics screen.......................................................................................... 98
plgriddata: Grid data from irregularly sampled data ......................................................... 98
plgspa: Get current subpage parameters ............................................................................100
120
plsesc: Set the escape character for text strings ................................................................121
vi
vii
viii
List of Tables
3-1. PLplot Terminal Output Devices .................................................................................................. 10
3-2. PLplot File Output Devices........................................................................................................... 10
3-3. Roman Characters Corresponding to Greek Characters................................................................ 28
16-1. Bounds on coordinates................................................................................................................116
ix
I. Introduction
Chapter 1. Introduction
The PLplot Plotting Library
PLplot is a library of C functions that are useful for making scientific plots from programs written in
C, C++, Fortran, Octave, Python, and Tcl/Tk. The PLplot project is being developed by a world-wide
team who interact via the facilities provided by SourceForge (http://sourceforge.net/projects/plplot)
The PLplot library can be used to create standard x-y plots, semi-log plots, log-log plots, contour plots,
3D plots, shade (gray-scale and color) plots, mesh plots, bar charts and pie charts. Multiple graphs (of
the same or different sizes) may be placed on a single page with multiple lines in each graph. Different
line styles, widths and colors are supported. A virtually infinite number of distinct area fill patterns may
be used. There are almost 1000 characters in the extended character set. This includes four different
fonts, the Greek alphabet and a host of mathematical, musical, and other symbols. The fonts can be
scaled to any desired size. A variety of output devices and file formats are supported including a metafile
format which can be subsequently rendered to any device/file. New devices and file formats can be easily
added by writing a driver routine. For example, we have recently added PNG and JPEG file drivers,
and a GNOME interactive driver is being developed.
PLplot was originally developed by Sze Tan of the University of Auckland in Fortran-77. Many of the
underlying concepts used in the PLplot package are based on ideas used in Tim Pearsons PGPLOT
package. Sze Tan writes:
Im rather amazed how far PLPLOT has traveled given its origins etc. I first used PGPLOT on the Starlink
VAX computers while I was a graduate student at the Mullard Radio Astronomy Observatory in Cambridge
from 1983-1987. At the beginning of 1986, I was to give a seminar within the department at which I wanted
to have a computer graphics demonstration on an IBM PC which was connected to a completely nonstandard graphics card. Having about a week to do this and not having any drivers for the card, I started
from the back end and designed PLPLOT to be such that one only needed to be able to draw a line or a
dot on the screen in order to do arbitrary graphics. The application programmers interface was made as
similar as possible to PGPLOT so that I could easily port my programs from the VAX to the PC. The
kernel of PLPLOT was modeled on PGPLOT but the code is not derived from it.
The C version of PLplot was developed by Tony Richardson on a Commodore Amiga. In the process,
several of the routines were rewritten to improve efficiency and some new features added. The program
structure was changed somewhat to make it easier to incorporate new devices. Additional features were
added to allow three-dimensional plotting and better access to low-level routines.
PLplot 5.0 is a continuation of our work on PLplot 4.0, which never got widely distributed. It became clear
during the work on 4.0 that in order to support an interactive driver under Unix (using Tcl/Tk), many
additions to the basic capabilities of the package were needed. So without stopping to fully document
and bug-fix the 4.0 additions, work on 5.0 was begun. The result is that a very capable PLplot-based
widget for the Tk toolkit has been written. This widget can manipulate the plot (zoom/pan, scale, orient,
change colors), as well dump it to any supported device. There are help menus and user customization
options. These are still in the process of being documented.
Other changes include the introduction of a new color palette (cmap1) for smooth color shaded images
(typically for 2d or 3d plots in which color represents function intensity), support for color fill plots,
and lots more cool stuff. The manual has been rewritten in LaTeXinfo, so that there is now a printed
version and an online (info) version of the document. The manual is still in a state of flux and will be
fleshed out in more detail in later updates.
Some of the improvements in PLplot 5.0 include: the addition of several new routines to enhance usage
from Fortran and design of a portable C to Fortran interface. Additional support was added for coordinate
mappings in contour plots and some bugs fixed. New labeling options were added. The font handling code
Chapter 1. Introduction
was made more flexible and portable. A portable PLplot metafile driver and renderer was developed,
allowing one to create a generic graphics file and do the actual rendering later (even on a different
system). The ability to create family output files was added. The internal code structure was dramatically
reworked, with elimination of global variables (for a more robust package), the drivers rewritten to
improve consistency, and the ability to maintain multiple output streams added. An XFig driver was
added. Other contributions include Clair Nielsens (LANL) X-window driver (very nice for high-speed
color graphics) and tektronix file viewer. At present, Maurice LeBrun and Geoff Furnish are the active
developers and maintainers of PLplot.
We have attempted to keep PLplot 5.0 backward compatible with previous versions of PLplot. However,
some functions are now obsolete, and many new ones have been added (e.g. new contouring functions,
variable get/set routines, functions that affect label appearance). Codes written in C that use PLplot
must be recompiled including the new header file plplot.h before linking to the new PLplot library.
PLplot is currently known to work on the following systems: Unix/Linux, OS/2, Mac, MS-DOS, and
Win9x. The Unix/Linux version is the best supported of these possibilities. The PLplot package is freely
distributable, but not in the public domain. See the Section called Copyrights for distribution criteria.
We welcome suggestions on how to improve this code, especially in the form of user-contributed enhancements or bug fixes. If PLplot is used in any published papers, please include an acknowledgment or
citation of our work, which will help us to continue improving PLplot. Please direct all communication
to the general PLplot mailing list, [email protected].
Chapter 1. Introduction
routines (see the Section called Plotting a Simple Graph in Chapter 2). For a discussion of the underlying
concepts of the plotting process and an introduction to some of the more complex routines (see Chapter
3). An alphabetical list of the user-accessible PLplot functions with detailed descriptions is given in the
reference section of the manual (see Chapter 16).
Because the PLplot kernel is written in C, standard C syntax is used in the description of each PLplot
function. The C and Fortran language interfaces are discussed in Appendix \ref{ap:lang}; look there if
you have difficulty interpreting the call syntax as described in this manual. The meaning of function
(subroutine) arguments is typically the same regardless of whether you are calling from C or Fortran
(but there are some exceptions to this). The arguments for each function are usually specified in terms
of PLFLT and PLINTthese are the internal PLplot representations for integer and floating point, and
are typically a long and a float (or an INTEGER and a REAL, for Fortran programmers). See Appendix
\ref{ap:lang} for more detail.
Also, you can use PLplot from C++ just as you would from C. No special classes are available at this
time, just use it as any other procedural type library. Simply include plplot.h, and invoke as you would
from C.
The output devices supported by PLplot are listed in Appendix \ref{ap:dev}, along with description
of the device driver--PLplot interface, metafile output, family files, and vt100/tek4010 emulators. In
Appendix\ref{ap:sys} the usage and installation for each system supported by PLplot is described (not
guaranteed to be entirely up-to-date; check the release notes to be sure).
Copyrights
The PLplot package may be distributed under the following terms:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is
but WITHOUT ANY
MERCHANTABILITY
Library General
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The text of this license is given in the file COPYING.LIB in the distribution directory. Exceptions are
noted below.
The intent behind distributing PLplot under the LGPL is to ensure that it continues to evolve in a
positive way, while remaining freely distributable. The package is considered a "library" even though
there are associated programs, such as plrender, pltek, plserver, and pltcl. The ties between these programs and the library are so great that I consider them as part of the library, so distribution under the
terms of the LGPL makes sense. Software developers are allowed and encouraged to use PLplot as an
integral part of their product, even a commercial product. Under the conditions of the LGPL, however,
the PLplot source code must remain freely available, including any modifications you make to it (if you
distribute a program based on the modified library). Please read the full license for more info.
Chapter 1. Introduction
Additional Copyrights
The startup code used in argument handling (utils/plrender.c and src/plargs.c) is partially derived
from xterm.c of the X11R5 distribution, and its copyright is reproduced here:
******************************************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard,
Massachusetts, and the Massachusetts Institute of Technology, Cambridge,
Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************************
Any file that is explicitly marked as "public domain" is free from any restriction on distribution.
Any file that has a explicit copyright notice may be distributed under the terms of both the LGPL and
whatever stated conditions accompany the copyright.
Credits
PLplot 5.0 was created through the effort of many individuals and funding agencies. We would like to
acknowledge the support (financial and otherwise) of the following institutions:
Duke University
Universite de Nice
Chapter 1. Introduction
Finally, thanks to all those who submitted bug reports and other suggestions.
Notes
1. http://sourceforge.net/projects/plplot
2. http://sourceforge.net/projects/plplot
3. http://plplot.sf.net/examples/index.html
Chapter 1. Introduction
II. Programming
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.
Initializing PLplot
Before any actual plotting calls are made, a graphics program must call plinit, is the main initialization
routine for PLplot. It sets up all internal data structures necessary for plotting and initializes the output
device driver. If the output device has not already been specified when plinit is called, a list of valid
output devices is given and the user is prompted for a choice. Either the device number or a device
keyword is accepted.
There are several routines affecting the initialization that must be called before plinit, if they are used.
The function plsdev allows you to set the device explicitly. The function plsetopt allows you to set any
command-line option internally in your code. The function plssub may be called to divide the output
device plotting area into several subpages of equal size, each of which can be used separately.
One advances to the next page (or screen) via pladv. If subpages are used, this can be used to advance
to the next subpage or to a particular subpage.
axis = 1: In addition to box and labels, draw the two axes X = 0 and Y = 0.
axis = 2: Same as axis = 1, but also draw a grid at the major tick interval.
Note: Logarithmic axes only affect the appearance of the axes and their labels, so it is up to the user
to compute the logarithms prior to passing them to plenv and any of the other routines. Thus, if a
graph has a 3-cycle logarithmic axis from 1 to 1000, we need to set xmin = log10(1) = 0.0, and xmax =
log10(1000) = 3.0.
For greater control over the size of the plots, axis labeling and tick intervals, more complex graphs
should make use of the functions plvpor, plvasp, plvpas, plwind, plbox, and routines for manipulating
axis labeling plgxax through plszax.
Drawing Points
plpoin and plsym mark out n points (x[i], y[i]) with the specified symbol. The routines differ only in
the interpretation of the symbol codes. plpoin uses an extended ASCII representation, with the printable
ASCII codes mapping to the respective characters in the current font, and the codes from 031 mapping
to various useful symbols. In plsym however, the code is a Hershey font code number. Example programs
are provided which display each of the symbols available using these routines.
plpoin(n , x , y , code );
plsym (n , x , y , code );
n (PLINT, input)
The number of points to plot.
x, y (PLFLT *, input)
Pointers to arrays of the coordinates of the n points.
code (PLINT, input)
Code number of symbol to draw
plline (n , x , y );
x, y (PLFLT, input)
Coordinates of the reference point.
dx, dy (PLFLT, input)
These specify the angle at which the text is to be printed. The text is written parallel to a line
joining the points (x, y) to (x+dx, y+dy) on the graph.
dx, dy (PLFLT, input)
These specify the angle at which the text is to be printed. The text is written parallel to a line
joining the points (x, y) to (x+dx, y+dy) on the graph.
just (PLFLT, input)
Determines justification of the string by specifying which point within the string is placed at the
reference point (x, y). This parameter is a fraction of the distance along the string. Thus if just =
0.0, the reference point is at the left-hand edge of the string. If just = 0.5, it is at the center and
if just = 1.0, it is at the right-hand edge.
text (char *, input)
Pointer to the string of characters to be written.
Area Fills
Area fills are done in the currently selected color, line style, line width and pattern style.
plfill fills a polygon. The polygon consists of n vertices which define the polygon.
n (PLINT, input)
The number of vertices.
x, y (PLFLT *, input)
Pointers to arrays with coordinates of the n vertices.
Finishing Up
Before the end of the program, always call plend to close any output plot files and to free up resources.
For devices that have separate graphics and text modes, plend resets the device to text mode.
In Case of Error
If a fatal error is encountered during execution of a PLplot routine then plexit is called. This routine
prints an error message, does resource recovery, and then exits. The user may specify an error handler
via plsexit that gets called before anything else is done, allowing either the user to abort the error
termination, or clean up user-specific data structures before exit.
Usage:
./x01c [options]
PLplot options:
-h
-v
-verbose
-debug
-dev name
-o name
-display name
-px number
-py number
-geometry geom
-wplt xl,yl,xr,yr
-mar margin
-a aspect
-jx justx
-jy justy
-ori orient
-freeaspect
-width width
-bg color
-ncol0 n
-ncol1 n
-fam
-fsiz size
-fbeg number
-finc number
-fflen length
-nopixmap
-db
-np
-server_name name
-server_host name
-server_port name
-user name
Output Devices
PLplot supports a variety of output devices, via a set of device drivers. Each driver is required to emulate
a small set of low-level graphics primitives such as initialization, line draw and page advance, as well
as be completely independent of the PLplot package as a whole. Thus a driver may be very simple, as
in the case of the many black and white file drivers (tektronix, etc.). More complicated and/or color
systems require a bit more effort by the driver, with the most effort required by an output device with
a graphical user interface, including menus for screen dumps, palette manipulation, and so forth. At
present only the tk driver does the latter on Unix systems. At present we arent pursuing a Macintosh
development effort due to a lack of time and expertise, but will assist anyone wanting to volunteer for
the job.
Note that if you always render to a PLplot metafile, you can always plrender them to new devices as
they become available.
The list of available devices presented when starting PLplot (via plstar) is determined at compile time.
When installing PLplot you may wish to exclude devices not available on your system in order to reduce
screen clutter. To include a specified device, simply define the appropriate macro constant when building
PLplot (see the installation instructions for your system).
The device drivers for PLplot terminal output at present are given in Table 3-1 while drivers for file
output are given in Table 3-2. The driver for OS/2 PM is available separately. See the section on OS/2
in the Appendix for more details.
Table 3-1. PLplot Terminal Output Devices
Device
keyword
driver file
X-Window Screen
Tcl/Tk widget
Linux console VGA
Xterm Window
Tektronix Terminal (4010)
Tektronix Terminal (4105/4107)
MS-Kermit emulator
Versaterm vt100/tek emulator
VLT vt100/tek emulator
Conex vt320/tek emulator
DG300 Terminal
NeXT display (unsupported)
GNOME display
xwin
tk
vga
xterm
tekt
tek4107t
mskermit
versaterm
vlt
conex
dg300
nx
gnome
xwin.c
tk.c
linuxvga.c
tek.c
tek.c
tek.c
tek.c
tek.c
tek.c
tek.c
dg300.c
next.c
gnome.c
keyword
plmeta
tekf
tek4107f
ps
psc
xfig
ljiip
driver file
plmeta.c
tek.c
tek.c
ps.c
ps.c
xfig.c
ljiip.c
10
keyword
ljii
driver file
ljii.c
hp7470
hpgl.c
hp7580
hpgl.c
lj_hpgl
imp
pbm
null
jpeg
png
cgm
hpgl.c
impress.c
pbm.c
null.c
gd.c
gd.c
cgm.c
Driver Functions
A dispatch table is used to direct function calls to whatever driver is chosen at run-time. Below are listed
the names of each entry in the PLDispatchTable dispatch table struct defined in plcore.h. The entries
specific to each device (defined in drivers/*.c) are typically named similarly but with pl_ replaced
by a string specific for that device (the logical order must be preserved, however). The dispatch table
entries are :
pl_MenuStr:
pl_DevName:
pl_type:
0 for file-oriented device, 1 for interactive (the null driver uses -1 here).
pl_init:
Initialize device. This routine may also prompt the user for certain device parameters or open
a graphics file (see Notes). Called only once to set things up. Certain options such as familying and
resolution (dots/mm) should be set up before calling this routine (note: some drivers ignore these).
pl_line:
pl_polyline:
pl_eop:
pl_bop:
Set up for plotting on a new page. May also open a new a new graphics file (see Notes).
pl_tidy:
pl_state:
pl_esc:
Handle change in PLStream state (color, pen width, fill attribute, etc).
Notes: Most devices allow multi-page plots to be stored in a single graphics file, in which case the graphics
file should be opened in the pl_init() routine, closed in pl_tidy(), and page advances done by calling
pl_eop and pl_bop() in sequence. If multi-page plots need to be stored in different files then pl_bop()
should open the file and pl_eop() should close it. Do NOT open files in both pl_init() and pl_bop() or
close files in both pl_eop() and pl_tidy(). It is recommended that when adding new functions to only
a certain driver, the escape function be used. Otherwise it is necessary to add a null routine to all the
other drivers to handle the new function.
11
Each command is written as a single byte, possibly followed by additional data bytes. The NEW_COLOR and
NEW_WIDTH commands each write 2 data bytes, the LINETO command writes 4 data bytes, and the LINE
command writes 8 data bytes. The most common instruction in the typical metafile will be the LINETO
command, which draws a continuation of the previous line to the given point. This data encoding is not
quite as efficient as the tektronix format, which uses 4 bytes instead of 5 here (1 command + 4 data),
however the PLplot encoding is far simpler to implement and more robust. The ESCAPE function writes
a second command character (opcode) followed by an arbitrary number of data bytes depending on the
value of the opcode. Note that any data written must be in device independent form to maintain the
transportability of the metafile so floating point numbers are not allowed.
The short usage message for plrender is printed if one inputs insufficient or invalid arguments, and is as
follows:
% plrender
No filename specified.
Usage:
plrender [options] [files]
plrender options:
12
The longer usage message goes into more detail, and is as follows:
% plrender -h
Usage:
plrender [options] [files]
plrender options:
-v
-i name
-b number
-e number
-p page
13
The options are generally self explanatory (family files are explained in the Section called Family File
Output). Most of these options have default values, and for those that dont plrender will prompt the
user. The -px and -py options are not so useful at present, because everything is scaled down by the
specified factor --- resulting in labels that are too small (future versions of plrender might allow changing
the label size as well).
Additional options may be added in future releases.
family files on output, rendering to any device that supports familying, including another metafile if
desired. The size of member files in this case is input through the argument list, and defaults to 1MB
if unspecified (this may be changed during the PLplot installation, however). plrender can also create a
single output file from a familied input metafile.
14
The output device is switched to text mode before the prompt is given, which causes the prompt to go
to the vt102 window under xterm and most vt100/tek4010 emulators.
Plotting Options:
< 1> xwin
X-Window (Xlib)
< 2> tk
Tcl/TK Window
< 3> xterm
Xterm Window
< 4> tekt
Tektronix Terminal (4010)
< 5> tek4107t
Tektronix Terminal (4105/4107)
< 6> mskermit
MS-Kermit emulator
< 7> versaterm Versaterm vt100/tek emulator
< 8> vlt
VLT vt100/tek emulator
< 9> plmeta
PLPLOT Native Meta-File
<10> tekf
Tektronix File (4010)
15
tek4107f
ps
psc
xfig
ljiip
ljii
null
Either the device number or a device keyword is accepted. Specifying the device by keyword is preferable
in aliases or scripts since the device number is dependent on the install procedure (the installer can choose
which device drivers to include). The device can be specified prior to the call to plinit by:
A call to plsdev.
The -dev device command line argument, if the programs command line arguments are being passed
to the PLplot function plParseInternalOpts.
Additional startup routines plstar and plstart are available but these are simply front-ends to plinit,
and should be avoided. It is preferable to call plinit directly, along with the appropriate setup calls, for
the greater amount of control this provides (see the example programs for more info).
Before plinit is called, you may modify the number of subpages the output device is divided into via a
call to plssub. Subpages are useful for placing several graphs on a page, but all subpages are constrained
to be of the same size. For greater flexibility, viewports can be used (see the Section called Defining the
Viewport for more info on viewports). The routine pladv is used to advance to a particular subpage or
to the next subpage. The screen is cleared (or a new piece of paper loaded) if a new subpage is requested
when there are no subpages left on the current page. When a page is divided into subpages, the default
character, symbol and tick sizes are scaled inversely as the square root of the number of subpages in the
vertical direction. This is designed to improve readability of plot labels as the plot size shrinks.
PLplot has the ability to write to multiple output streams. An output stream corresponds to a single
logical device to which one plots independent of all other streams. The function plsstrm is used to switch
between streams -- you may only write to one output stream at a time. At present, an output stream is
not limited by the type of device, however, it may not be wise to attempt opening two terminal devices.
An example usage for the creation of multiple streams is as follows:
#include "plplot.h"
main()
{
int nx = 2, ny = 2;
plssub(nx, ny);
plsdev("xwin");
plinit();
hplots for stream 0i
plsstrm(1);
plssub(nx, ny);
plsdev("plmeta");
plsfnam("tst.plm");
16
and so on, for sending output simultaneously to an X-window and a metafile. The default stream corresponds to stream number zero. At present, the majority of output drivers can only be used by a single
stream (exceptions include the metafile driver and X-window driver). Also see example program 14 (note:
only the C version is available, although it can be done equally well from Fortran).
At the end of a plotting program, it is important to close the plotting device by calling plend. This
flushes any internal buffers and frees any memory that may have been allocated, for all open output
streams. You may call plend1 to close the plotting device for the current output stream only. Note that
if PLplot is initialized more than once during a program to change the output device, an automatic call
to plend1 is made before the new device is opened for the given stream.
Initialise FreeType
Next, we have to initialise the FreeType library. For the gd.c driver this is done via two separate functions
due to the order that dependent information is initialised in the driver.
The "level 1" initialisation of FreeType does two things: 1) calls plD_FreeType_init(pls), which in turn
allocates memory to the pls->FT structure; and 2) stores the location of the call back routine.
void init_freetype_lv1 (PLStream *pls)
{
17
This initialisation routine is called at the end of plD_init_png_Dev(PLStream *pls) in the gd.c driver:
if (freetype)
{
pls->dev_text = 1; /* want to draw text */
init_freetype_lv1(pls);
FT=(FT_Data *)pls->FT;
FT->smooth_text=smooth_text;
}
"freetype" is a local variable which is parsed through plParseDrvOpts to determine if the user wanted
FreeType text. In that case pls->dev_text is set to 1 to indicate the driver will be rendering its own
text. After that, we always use pls->dev_text to work out if we want FreeType or not.
Similarly, "smooth_text" is a local variable passed through plParseDrvOpts to find out if the user wants
smoothing. Since there is nothing in PLStream to track smoothing, we have to set the FT->smooth_text
flag as well at this time.
The "level 2" initialisation function initialises everything else required for using the FreeType library
but has to be called after the screen resolution and dpi have been set. Therefore, it is called at the end
of plD_init_png(), where it looks like:
if (pls->dev_text)
{
init_freetype_lv2(pls);
}
if (FT->smooth_text==1)
{
FT->ncol0_org=pls->ncol0;
/* save a copy of the original size of ncol0 */
FT->ncol0_xtra=NCOLOURS-(pls->ncol1+pls->ncol0);
/* work out how many free slots we have */
FT->ncol0_width=FT->ncol0_xtra/(pls->ncol0-1);
/* find out how many different shades of anti-a
if (FT->ncol0_width>64) FT->ncol0_width=64;
/* set a maximum number of shades */
plscmap0n(FT->ncol0_org+(FT->ncol0_width*pls->ncol0));
/* redefine the size of cmap0 */
/* the level manipulations are to turn off the plP_state(PLSTATE_CMAP0)
* call in plscmap0 which (a) leads to segfaults since the GD image is
18
FT->scale is a scaling factor to convert coordinates. This is used by the gd.c and some other drivers
to scale back a larger virtual page and this eliminate the "hidden line removal bug". Set it to 1 if your
device driver doesnt use any scaling.
Some coordinate systems have zero on the bottom, others have zero on the top. FreeType does it one
way, and most everything else does it the other. To make sure everything is working ok, we have to "flip"
the coordinates, and to do this we need to know how big in the Y dimension the page is, and whether
we have to invert the page or leave it alone.
FT->invert_y=1 tells us to invert the y-coordinates, FT->invert_y=0 will not invert the coordinates.
We also do some computational gymnastics to "expand" cmap0 if the user wants anti-aliased text.
Basically, you have to work out how many spare colours there are in the driver after cmap0 and cmap1
are done, then set a few variables in FT to let the render know how many colours its going to have at
its disposal, and call plscmap0n to resize cmap0. The call to pl_set_extended_cmap0 does the remaining
part of the work. Note it essential to protect that call by the pls->level manipulations for the reasons
stated.
19
#ifdef HAVE_FREETYPE
FT_Data *FT=(FT_Data *)pls->FT;
plscmap0n(FT->ncol0_org);
plD_FreeType_Destroy(pls);
#endif
free_mem(pls->dev);
}
where in the case of plvpor and plvpas, the arguments are given in normalized subpage coordinates which
are defined to run from 0.0 to 1.0 along each edge of the subpage. Thus for example,
20
A further routine plvsta is available which sets up a standard viewport within the current subpage with
suitable margins on each side of the viewport. This may be used for simple graphs, as it leaves enough
room for axis labels and a title. This standard viewport is that used by plenv (See the Section called
Setting up a Standard Window ).
Another way to get a specified aspect ratio is via the routine plsasp [not!.. fix this], which sets the
global aspect ratio and must be called prior to plstar. An aspect ratio of 0.0 corresponds to natural
dimensions (i.e. fill the page); any positive value will give the specified aspect ratio. This scaling of plots
is actually done in the driver, and so may not work for all output devices (note that plrender is capable
of scaled aspect ratio plots to any device whether that device supports scaling or not). In such scaled
plots, absolute plotting is done in the scaled coordinate system.
Note that each of the arguments is a floating point number, and so the decimal points are required. If
the order of either the X limits or Y limits is reversed, the corresponding axis will point in the opposite
sense, (i.e., right to left for X and top to bottom for Y). The window must be defined before any calls
to the routines which actually draw the data points. Note however that plwind may also be called to
21
Another routine pllab provides for text labels for the bottom, left hand side and top of the viewport.
These labels are not clipped, even though they lie outside the viewport (but they are clipped at the
subpage boundaries). pllab actually calls the more general routine plmtex which can be used for plotting
labels at any point relative to the viewport. For our example, we may use
pllab("V#dCE#u (Volts)", "I#dC#u (mA)", "TRANSISTOR CHARACTERISTICS");
Note that #d and #u are escape sequences (see the Section called Escape Sequences in Text) which allow
subscripts and superscripts to be used in text. They are described more fully later in this chapter.
The appearance of axis labels may be further altered by auxiliary calls to plprec, plschr, plsxax, plsyax,
and plszax. The routine plprec is used to set the number of decimal places precision for axis labels, while
plschr modifies the heights of characters used for the axis and graph labels. Routines plsxax, plsyax,
and plszax are used to modify the digmax setting for each axis, which affects how floating point labels
are formatted.
The digmax variable represents the maximum field width for the numeric labels on an axis (ignored if less
than one). If the numeric labels as generated by PLplot exceed this width, then PLplot automatically
switches to floating point representation. In this case the exponent will be placed at the top left for a
vertical axis on the left, top right for a vertical axis on the right, and bottom right for a horizontal axis.
For example, lets suppose that we have set digmax = 5 via plsyax, and for our plot a label is generated
at y = 0.0000478. In this case the actual field width is longer than digmax, so PLplot switches to floating
point. In this representation, the label is printed as simply 4.78 with the 10-5 exponent placed separately.
The determination of maximum length (i.e. digmax) for fixed point quantities is complicated by the fact
that long fixed point representations look much worse than the same sized floating point representation.
Further, a fixed point number with magnitude much less than one will actually gain in precision when
written as floating point. There is some compensation for this effect built into PLplot, thus the internal
representation for number of digits kept (digfix) may not always match the users specification (via
digmax). However, it will always be true that digfix digmax. The PLplot defaults are set up such that
good results are usually obtained without user intervention.
Finally, after the call to plbox, the user may call routines plgxax, plgyax, or plgzax to obtain information
about the window just drawn. This can be helpful when deciding where to put captions. For example, a
typical usage would be to call plgyax to get the value of digits, then offset the y axis caption by that
amount (plus a bit more) so that the caption floats just to the outside of the numeric labels. Note that
the digits value for each axis for the current plot is not correct until after the call to plbox is complete.
22
To return to a continuous line, just call plstyl with first argument set to zero. You can use pllsty to
choose between 8 different predefined styles.
23
To set up a symmetrical crosshatch pattern with lines directed 30 degrees above and below the horizontal
and spaced 1.5 mm apart use:
*inc = 300;
*(inc+1) = -300;
*del = 1500;
*(del+1) = 1500;
plpat(2, inc, del);
Setting Color
Normally, color is used for all drivers and devices that support it within PLplot subject to the condition
that the user has the option of globally turning off the color (and subsequently turning it on again if so
desired) using plscolor.
The PLplot color model utilizes two color maps which can be used interchangeably. However, color map0
(discussed in the Section called Color Map0 ) has discrete colors with no particular order and is most
suited to coloring the background, axes, lines, and labels, and color map1 (discussed in the Section
called Color Map1 ) has continuously changing colors and is most suited to plots (see the Section called
Contour and Shade Plots) in which data values are represented by colors.
Color Map0
Color map0 is most suited to coloring the background, axes, lines, and labels. Generally, the default color
map0 palette of 16 colors is used. (examples/c/x02c.c illustrates these colors.) The default background
color is taken from the index 0 color which is black by default. The default foreground color is red.
There are a number of options for changing the default red on black colors. The user may set the index
0 background color using the command-line bg parameter or by calling plscolbg (or plscol0 with a 0
index) before plinit. During the course of the plot, the user can change the foreground color as often as
desired using plcol0 to select the index of the desired color.
For more advanced use it is possible to define an arbitrary map0 palette of colors. The user may set the
number of colors in the map0 palette using the command-line ncol0 parameter or by calling plscmap0n.
plscol0 sets the RGB value of the given index which must be less than the maximum number of colors
(which is set by default, by command line, by plscmap0n, or even by plscmap0). Alternatively, plscmap0
sets up the entire map0 color palette. For all these ways of defining the map0 palette any number of
colors are allowed in any order, but it is not guaranteed that the individual drivers will actually be able
to use more than 16 colors.
Color Map1
Color map1 is most suited to plots (see the Section called Contour and Shade Plots) in which data values
are represented by colors. The data are scaled to the input map1 range of floating point numbers between
24
This second example illustrates doing the same thing in HLS space.
i[0] = 0.;
i[1] = 1.;
/* Hue does not matter for zero saturation.*/
h[0] = 0.;
h[1] = 0.;
/* Lightness varies through its full range.*/
l[0] = 0.;
l[1] = 1.;
/* Saturation is zero for a gray scale.*/
25
This final example using plscmap1l illustrates how the default map1 color pallette is set with just 4
control points (taken from src/plctrl.c).
/*--------------------------------------------------------------------------*\
* plcmap1_def()
*
* Initializes color map 1.
*
* The default initialization uses 4 control points in HLS space, the two
* inner ones being very close to one of the vertices of the HLS double
* cone. The vertex used (black or white) is chosen to be the closer to
* the background color. If you dont like these settings you can always
* initialize it yourself.
\*--------------------------------------------------------------------------*/
static void
plcmap1_def(void)
{
PLFLT i[4], h[4], l[4], s[4], vertex = 0.;
/* Positions of control points */
i[0]
i[1]
i[2]
i[3]
=
=
=
=
0; /* left boundary */
0.45; /* just before center */
0.55; /* just after center */
1; /* right boundary */
=
=
=
=
/* Set lightness */
l[0] = 0.5; /* low */
l[1] = vertex; /* bg */
l[2] = vertex; /* bg */
26
/* high */
=
=
=
=
1;
1;
1;
1;
c_plscmap1l(0, 4, i, h, l, s, NULL);
}
Finally, plscmap1 is an additional method of setting the map1 color palette directly using RGB space.
No interpolation is used with plscmap1 so it is the programmers responsibility to make sure that the
colors vary smoothly. Here is an example of the method taken from examples/c/x08c.c which sets (yet
again) the gray-scale color pallette.
for (i=0;i<n_col;i++)
rr[i] = gg[i] = bb[i] = i*256/n_col;
plscmap1(rr,gg,bb,n_col);
font = 2:
roman font
font = 3:
italic font
font = 4:
script font
The routine plschr is used to set up the size of subsequent characters drawn. The actual height of a
character is the product of the default character size and a scaling factor. If no call is made to plschr,
27
#d:
#b:
##:
number symbol
#+:
#-:
#gx:
#fn:
#fr:
#fi:
#fs:
#(nnn):
Sections of text can have an underline or overline appended. For example, the string S(freq) is obtained
by specifying "#+S#+(#-freq#-)".
Greek letters are obtained by #g followed by a Roman letter. Table 3-3 shows how these letters map into
Greek characters.
Table 3-3. Roman Characters Corresponding to Greek Characters
28
Roman
Greek
Roman
Greek
Roman
Greek
Roman
Greek
A reasonable range for the x coordinate of the two-dimensional window is -2.5 to +2.5, since the length
of the diagonal across the base of the normalized box is sqrt(22+42) = 2 sqrt(5), which fits into this
coordinate range. A reasonable range for the y coordinate of the two dimensional window in this case is
-2.5 to +4, as the the projection of the normalized box lies in this range for the allowed range of viewing
angles.
The routine plwind or plenv is used in the usual way to establish the size of the two-dimensional window.
The routine plw3d must then be called to establish the range of the three dimensional world coordinates,
the size of the normalized box and the viewing angles. After calling plw3d, the actual surface is drawn
by a call to plot3d.
For example, if the three-dimensional world-coordinate ranges are -10.0 x 10.0, -3.0 y +7.0,
and 0.0 z 8.0, we could use the following statements:
xmin2d = -2.5;
29
The values of the function are stored in a two-dimensional array z[][] where the array element z[i][j]
contains the value of the function at the point xi, yj. (The two-dimensional array z is a vectored array
instead of a fixed size array. z points to an array of pointers which each point to a row of the matrix.)
Note that the values of the independent variables xi and yj do not need to be equally spaced, but they
must lie on a rectangular grid. Thus two further arrays x[nx] and y[ny] are required as arguments to
plot3d to specify the values of the independent variables. The values in the arrays x and y must be
strictly increasing with the index. The argument opt specifies how the surface is outlined. If opt = 1, a
line is drawn representing z as a function of x for each value of y, if opt = 2, a line is drawn representing
z as a function of y for each value of x, and if opt = 3, a net of lines is drawn. The first two options
may be preferable if one of the independent variables is to be regarded as a parameter, whilst the third
is better for getting an overall picture of the surface. If side is equal to one then sides are drawn on the
figure so that the graph doesnt appear to float.
The routine plmesh is similar to plot3d, except that it is used for drawing mesh plots. Mesh plots allow
you to see both the top and bottom sides of a surface mesh, while 3D plots allow you to see the top side
only (like looking at a solid object). The side option is not available with plmesh.
Labeling a three-dimensional or mesh plot is somewhat more complicated than a two dimensional plot
due to the need for skewing the characters in the label so that they are parallel to the coordinate axes.
The routine plbox3 thus combines the functions of box drawing and labeling.
30
where z is the two-dimensional array of size nx by ny containing samples of the function to be contoured.
(z is a vectored two-dimensional array as described in the previous section. It is not a fixed-size twodimensional array.) The parameters kx, lx, ky and ly specify the portion of z that is to be considered.
The array clevel of length nlevel is a list of the desired contour levels.
The path of each contour is initially computed in terms of the values of the array indices which range
from 0 to nx-1 in the first index and from 0 to ny-1 in the second index. Before these can be drawn in the
current window (see the Section called Defining the Window ), it is necessary to convert from these array
indices into world coordinates. This is done by passing a pointer pltr to a user-defined transformation
function to plcont. For C use of plcont (and plshade, see next subsection) we have included directly
in the PLplot library the following transformation routines: pltr0 (identity transformation or you can
enter a NULL argument to get the same effect); pltr1 (linear interpolation in singly dimensioned coordinate arrays); and pltr2 (linear interpolation in doubly dimensioned coordinate arrays). Examples
of the use of these transformation routines are given in examples/c/x09c.c, examples/c/x14c.c, and
examples/c/x16c.c. These same three examples also demonstrate a user-defined transformation function
mypltr which is capable of arbitrary translation, rotation, and/or shear. By defining other transformation
subroutines, it is possible to draw contours wrapped around polar grids etc.
When called from Fortran, this routine has the same effect as when invoked from C. The interpretation
of all parameters (see plcont) is also the same except there is no transformation function supplied as the
last parameter. Instead, a 6-element array specifying coefficients to use in the transformation is supplied
via the named common block plplot (see code). Since this approach is somewhat inflexible, the user is
recommended to call either of plcon0, plcon1, or plcon2 instead.
The three routines recommended for use from Fortran are plcon0, plcon1, and plcon2. These routines
are similar to existing commercial plot package contour plotters in that they offer successively higher
complexity, with plcon0 utilizing no transformation arrays, while those used by plcon1 and plcon2 are
one and two dimensional, respectively. The call syntax for each is
call plcon0 (z , nx , ny , kx , lx , ky , ly , clevel , nlevel );
31
assuming the user had already set up arrays r and theta to specify the (r, ) values at the gridpoints
in his system. For this example, it is recommended that the user add an additional cell in theta such
that xg(i, NY+1) = xg(i, 1) and yg(i, NY+1) = yg(i, 1) so that the contours show the proper periodic
behavior in (see also example program 9).
The transformation function not only specifies the transformation at grid points, but also at intermediate
locations, via linear interpolation. For example, in the pltr1 transformation function used by plcon1,
the 1-d interpolation to get tx as a function of x looks like (in C):
ul = (PLINT)x;
ur = ul + 1;
du = x - ul;
xl = *(xg+ul);
xr = *(xg+ur);
*tx = xl * (1-du)
xr * du;
xr * dx
32
Your program must run on a machine that does not have PLplot installed from the sources.
The program should be installed in a self-contained directory structure (which can be /usr/local or
c:\program files or whatever, but need not be so).
Under Linux, the easiest way to install a binary version of PLplot on a users machine is to use PLplot
deb binary packages for the Debian1 distribution, and PLplot rpm binary packages for rpm-based distributions. (See the Resources area2 of the PLplot web site for locations of debs and rpms.) Build the
application on the build machine using the results of the plplot-config --cflags --libs command,
and copy the resulting executable(s) to the users machines.
Under Unix (and also under Linux if you would prefer to use a newer version of PLplot than is available
in the debs or rpms), a good way to deploy binary PLplot and applications that depend on that binary
PLplot on users machines is as follows:
Use the ./configure option --prefix=/usr/local/plplot (or some other unique but consistent
directory that is available on the build machine and all users machines).
Unpack that tarball on all users machines in the same location /usr/local/plplot.
Build the application(s) on the build machine using the results of the plplot-config --cflags
--libs command, and copy the resulting executable(s) to the users machines. Since the PLplot install
location is consistent on all machines, the application should work the same way on all machines.
On Windows, and also those rare Linux/Unix cases where you cannot install the PLplot install tree in
a consistent location on users machines, then there are some additional options you need to consider.
There are three situations depending on how you configure and build the PLplot libraries:
1. You use the static versions of the PLplot libraries and devices which are not dynamically loaded.
2. You use the shared versions of the PLplot libraries and devices which are not dynamically loaded.
33
In the first case the program will contain all the code it needs to work, but to run successfully, it needs
to find the font files, plstnd5.fnt and plxtnd5.fnt. The mechanism used in PLplot to find these files is
fairly simple:
It looks at a number of built-in places, determined at the time the PLplot library itself was installed
and built. For deployment these places are irrelevant in general.
It looks at the environment variables PLPLOT_LIB and PLPLOT_HOME. (Actually, this happens
only, if the corresponding compiler macros PLPLOT_LIB_ENV and PLPLOT_HOME_ENV were
defined at compile time.)
Note: This is also the place to put the geographical map files, if you happen to use them.
The environment variables should point to the directory holding the two font files or the one above (one
variable is enough though):
PLPLOT_HOME should point to the directory that holds a subdirectory lib which in turn holds
these files.
Most UNIX, BSD and Linux systems use an environment variable LD_LIBRARY_PATH which
indicates directories where shared libraries can be found. Some use SHLIB_PATH, like HPUX.
On Windows the PATH variable is used to find the DLLs, but beware: Windows uses a number of
places to find the DLLs a program needs and the ordering seems to depend on some intricate details.
It seems easiest and safest to put the DLLs in the same directory as your program.
In the third (default) case, the PLplot fonts and maps are found as in the first case, and the shared
libraries are found as in the second case, but in addition the separated dynamic devices have to be found
as well.
When PLplot uses dynamic devices, it first builds up a list of them, by examining a directory which
contains files describing those devices: the *.rc files. Each of these files indicates what the relevant
properties for the device or devices. Then when the device is actually needed, the corresponding shared
object (or plug-in or DLL depending on your terminology) is dynamically loaded.
34
PLPLOT_HOME or PLPLOT_LIB to indicate the position of font files (and also of the various
geographic maps)
The following files being part of PLplot must be distributed along with your program:
The font files (plstnd5.fnt and plxtnd5.fnt) and, possibly, if you use them, the geographic map
files.
The device description files and the device shared object files
All the environment variables, except LD_LIBRARY_PATH and equivalents, can be set within the
program (by using a small configuration file or by determining the position of the files relative to the
programs location). They just have be set before PLplot is initialised.
Notes
1. http://www.debian.org
2. http://plplot.sourceforge.net/resources/index.html
3. UNIX-like systems libraries can be static or shared, the first type becoming part of the program, the
second existing as a separate file. On Windows the terms are respectively static and dynamic (the
latter type is also known as DLL).
35
36
The Tk Driver
is the prototype of a whole new interaction paradigm. See next chapter.
37
38
39
40
Chapter 7. C Language
(OLD, NEEDS DOCUMENTATION UPDATING) The argument types given in this manual (PLFLT
and PLINT) are typedefs for the actual argument type. A PLINT is actually a type long and should not
be changed. A PLFLT can be either a float or double; this choice is made when the package is installed
and on a Unix system (for example) may result in a PLplot library named libplplot.a in single precision
and libplplotd.a in double precision.
These and other constants used by PLplot are defined in the main header file plplot.h, which must be
included by the user program. This file also contains all of the function prototypes, machine dependent
defines, and redefinition of the C-language bindings that conflict with the Fortran names (more on
this later). plplot.h obtains its values for PLFLT, PLINT, and PLARGS (a macro for conditionally
generating prototype argument lists) from FLOAT (typedef), INT (typedef), and PROTO (macro),
respectively. The latter are defined in the file chdr.h. The user is encouraged to use FLOAT, INT, and
PROTO in his/her own code, and modify chdr.h according to taste. It is not actually necessary to
declare variables as FLOAT and INT except when they are pointers, as automatic conversion to the
right type will otherwise occur (if using a Standard C compiler; else K&R style automatic promotion
will occur). The only code in plplot.h that directly depends on these settings is as follows:
#include "plplot/chdr.h"
/* change from chdr.h conventions to plplot ones */
typedef FLOAT PLFLT;
typedef INT
PLINT;
#define PLARGS(a) PROTO(a)
PLplot is capable of being compiled with Standard C (ANSI) mode on or off. This is toggled via the
macro PLSTDC, and set automatically if __STDC__ is defined. If PLSTDC is defined, all functions
are prototyped as allowed under Standard C, and arguments passed exactly as specified in the prototype.
If PLSTDC is not defined, however, function prototypes are turned off and K&R automatic argument
promotion will occur, e.g. float → double, int → long. There is no middle ground! A PLplot
library built with PLSTDC defined will not work (in general) with a program built with PLSTDC
undefined, and vice versa. It is possible in principle to build a library that will work under both Standard
C and K&R compilers simultaneously (i.e. by duplicating the K&R promotion with the Standard C
prototype), but this seems to violate the spirit of the C standard and can be confusing. Eventually we
will drop support for non-standard C compilers but for now have adopted this compromise.
In summary, PLplot will work using either a Standard or non-standard C compiler, provided that you :
Make sure all pointer arguments are of the correct type (the compiler should warn you if you forget,
so dont worry, be happy).
Do not link a code compiled with PLSTDC defined to a PLplot library compiled with PLSTDC
undefined, or vice versa.
Note that some Standard C compilers will give warnings when converting a constant function argument
to whatever is required by the prototype. These warnings can be ignored.
43
Chapter 7. C Language
The one additional complicating factor concerns the use of stub routines to interface with Fortran (see
the following section for more explanation). On some systems, the Fortran and C namespaces are set
up to clobber each other. More reasonable (from our viewpoint) is to agree on a standard map between
namespaces, such as the appending of an underscore to Fortran routine names as is common on many
Unix-like systems. The only case where the shared Fortran/C namespaces do any good is when passing
a pointer to a like data type, which represents only a small fraction of the cases that need to be handled
(which includes constant values passed on the stack, strings, and two-dimensional arrays).
There are several ways to deal with this situation, but the least messy from a users perspective is to
redefine those PLplot C function names which conflict with the Fortran-interface stub routines. The
actual function names are the same as those described in this document, but with a c_ prepended.
These macro definitions appear in the plplot.h header file and are otherwise harmless. Therefore you can
(and should) forget that most of the names are being redefined to avoid the conflict and simply adhere
to the bindings as described in this manual. Codes written under old versions of PLplot (previous to
5.0) will require a recompile, however.
For more information on calling PLplot from C, please see the example C programs (x01c.c through
x19c.c) distributed with PLplot.
44
typically with n declared as type integer and x, y declared as type real (arrays in this case). Each C
language type used in the text translates roughly as follows:
PLFLT
PLINT
char *
PLFLT *
PLFLT **
real
integer
character
real or real array
real array
"string"
string
array[0]
array(1)
In C there are two ways to pass a variable --- by value (the default) or by reference (pointer), whereas
only the latter is used by Fortran. Therefore when you see references in the text to either an ordinary
argument or a pointer argument (e.g. *data), you simply use an ordinary Fortran variable or array name.
The PLplot library comes with a set of Fortran interface routines that allow the exact same call syntax
(usually) regardless of whether calling from C or Fortran. In some cases, this means the subroutine name
exceeds 8 characters in length. Nearly every Fortran compiler available today allows subroutine names
longer than 8 characters, so this should not be a problem (although if it ever is, in principle a truncated
name could be defined for that platform).
These stub routines handle transforming the data from the normal Fortran representation to that
typically used in C. This includes:
where x and y are arrays with 6 elements and you want to plot symbol 9. As strange as it seems (at
least to C programmers) the constants 6 and 9 are passed by reference. This will actually call the
following C stub routine (included in entirety)
#include "plplot/plstubs.h"
45
All this stub routine does is convert the number of points (*n and the symbol *code to call by value
(i.e. pushes their value on the stack) and then calls the C plpoin library routine.
This all seems a little messy, but is very user friendly. Fortran and C programmers can use the same
basic interface to the library, which is a powerful plus for this method. The fact that stub routines are
being used is completely transparent to the Fortran programmer.
46
47
48
49
Namespace Management
The PLplot C API is composed of a set of drawing functions, all prefixed with "pl", in an effort to
prevent namespace collision. However, the prefix "pl" is gratuitous, and in particular is unnecessary in
a C++ context. The plstream class mirrors most of the PLplot C API, but does so by dropping the
"pl" prefix. The plstream class thus serves to collect the PLplot drawing functions into a scope in which
collisions with other similarly named functions is not a concern. So, where a C programmer might write:
plsstrm( 1 );
plenv( ... );
plline( ... );
Is that an important benefit? The utility varies with the number of output streams in use in the program.
plmkstrm() is replaced by object declaration. plsstrm() is replaced by method invocation on the desired
output stream object. plgstrm() is rendered irrelevant.
The skeptic may say, "But you have to type the same number of characters! Youve replaced pl with
p., except it could be worse for a longer object name." True. BUT, in this new scheme, most plots will
not be generated by invoking methods on a specific stream object, but rather by deriving from plstream,
and invoking methods of "this" object. See the section on derivation below.
50
In this way the C++ user is completely freed from the tyranny of moronic data layout constraints
imposed by PLplots C or Fortran API.
Cat { ... };
Dog { ... };
Bear { ... };
Fish { ... };
51
plot(
plot(
plot(
plot(
const
const
const
const
Cat& c ) { ... }
Dog& d ) { ... }
Bear& b ) { ... }
Fish& f ) { ... }
};
Presumably the PLplot user community can think of even more imaginative uses... :-).
52
53
All the normal Tcl rules apply, there is nothing special about the PLplot extension commands. So, you
could write the above as:
set xmin 0; set xmax 1; set ymin 0; set ymax 1
set just 0; set axis 0
set xlab (x)
set ylab (y)
set title "The title of the graph"
plenv $xmin $xmax $ymin $ymax $just $axis
pllab $xlab $ylab $title
for example. Not that there is any reason to be loquacious for its own sake, of course. The point is
that you might have things like the plot bounds or axis labels stored in Tcl variables for some other
reason (tied to a Tk entry widget maybe, or provided as the result of one of your application specific
Tcl extension commands, etc), and just want to use standard Tcl substitution to make the PLplot calls.
Go ahead and try it! Enter pltcl to start up the PLplot extended Tcl shell, and type (or paste) in the
commands. Or put them in a file and source it. By this point it should be clear how incredibly easy it
is to use the PLplot Tcl language binding.
In order to accommodate the ubiquitous requirement for matrix oriented data in scientific applications,
and in the PLplot API in particular, PLplot 5.0 includes a Tcl extension for manipulating matrices in
Tcl. This Tcl Matrix Extension provides a straightforward and direct means of representing one and two
dimensional matrices in Tcl. The Tcl Matrix Extension is described in detail in the next section, but we
mention its existence now just so that we can show how the PLplot Tcl API works. Many of the PLplot
Tcl API functions accept Tcl matrices as arguments. For instance, in C you might write:
float x[100], y[100];
/* code to initialize x and y */
54
plline( 100, x, y );
Some of the PLplot C function calls use pointer arguments to allow retrieval of PLplot settings. These
are implemented in Tcl by changing the value of the variable whose name you provide. For example:
pltcl> plgxax
wrong # args: should be "plgxax digmax digits
pltcl> set digmax 0
0
pltcl> set digits 0
0
pltcl> plgxax digmax digits
pltcl> puts "digmax=$digmax digits=$digits"
digmax=4 digits=0
"
This example shows that each PLplot Tcl command is designed to issue an error if you invoke it incorrectly, which in this case was used to remind us of the correct arguments. We then create two Tcl
variables to hold the results. Then we invoke the PLplot plgxax function to obtain the label formatting
information for the x axis. And finally we print the results.
People familiar with Tcl culture may wonder why the plg* series functions dont just pack their results
into the standard Tcl result string. The reason is that the user would then have to extract the desired
field with either lindex or regexp, which seems messy. So instead, we designed the PLplot Tcl API to
look and feel as much like the C API as could reasonably be managed.
In general then, you can assume that each C function is provided in Tcl with the same name and same
arguments (and one or two dimensional arrays in C are replaced by Tcl matrices). There are only a few
exceptions to this rule, generally resulting from the complexity of the argument types which are passed
to some functions in the C API. Those exceptional functions are described below, all others work in the
obvious way (analogous to the examples above).
See the Tcl example programs for extensive demonstrations of the usage of the PLplot Tcl API. To run
the Tcl demos:
% pltcl
pltcl> source tcldemos.tcl
pltcl> 1
pltcl> 2
55
constructs two matrices. x is a float matrix, with one dimension and 100 elements. y is an integer matrix,
and has 2 dimensions each of size 64.
Additionally, an initializer may be specified, with a syntax familiar from C. For example:
matrix x f 4 = { 1.5, 2.5, 3.5, 4.5 }
A Tcl matrix is a command, and as longtime Tcl users know, Tcl commands are globally accessible. The
PLplot Tcl Matrix extension attempts to lessen the impact of this by registering a variable in the local
scope, and tracing it for insets, and deleting the actual matrix command when the variable goes out of
scope. In this way, a Tcl matrix appears to work sort of like a variable. It is, however, just an illusion, so
you have to keep this in mind. In particular, you may want the matrix to outlive the scope in which it
was created. For example, you may want to create a matrix, load it with data, and then pass it off to a
Tk megawidget for display in a spreadsheet like form. The proc which launches the Tk megawidget will
complete, but the megawidget, and the associated Tcl matrix are supposed to hang around until they
are explicitly destroyed. To achieve this effect, create the Tcl matrix with the -persist flag. If present
(can be anywhere on the line), the matrix is not automatically deleted when the scope of the current
proc (method) ends. Instead, you must explicitly clean up by using either the delete matrix command
or renaming the matrix command name to {}. Now works correctly from within [incr Tcl].
As mentioned above, the result of creating a matrix is that a new command of the given name is added
to the interpreter. You can then evaluate the command, providing indices as arguments, to extract the
data. For example:
pltcl> matrix x f = {1.5, 2.5, 3.5, 4.5}
insufficient dimensions given for Matrix operator "x"
pltcl> matrix x f 4 = {1.5, 2.5, 3.5, 4.5}
pltcl> x 0
1.500000
pltcl> x 1
2.500000
pltcl> x 3
4.500000
pltcl> x *
1.500000 2.500000 3.500000 4.500000
pltcl> puts "x\[1\]=[x 1]"
x[1]=2.500000
pltcl> puts "x\[*\] = :[x *]:"
56
Note from the above that the output of evaluating a matrix indexing operation is suitable for use in
condition processing, list processing, etc.
You can assign to matrix locations in a similar way:
pltcl> x 2 = 7
pltcl> puts ":[x *]:"
:1.500000 2.500000 7.000000 4.500000:
pltcl> x * = 3
pltcl> puts ":[x *]:"
Note that the * provides a means of obtaining an index range, and that it must be separated from the =
by a space. Future versions of the Tcl Matrix extension may allow alternative ways of specifying index
ranges and may assign the obvious meaning to an expression of the form:
x *= 3
and in C:
int wackyCmd( ClientData clientData, Tcl_Interp *interp,
int argc, char *argv[] )
{
tclMatrix *w;
w = Tcl_GetMatrixPtr( interp, argv[1] );
...
57
There are other things you can do too, see the definitions of the TclMatFloat and TclMatInt classes in
tclMatrix.h.
In other words, make a function for handling the matrix extension subcommand, with the same function
signature (prototype) as tclMatrixXtnsnProc, and register the subcommand name along with the function
pointer. For example, xtk04.c has:
int mat_max( tclMatrix *pm, Tcl_Interp *interp,
int argc, char *argv[] )
{
58
Then, inside the application initialization function (Tcl_AppInit() to long time Tcl users):
Tcl_MatrixInstallXtnsn( "max", mat_max );
Tcl_MatrixInstallXtnsn( "min", mat_min );
Your imagination is your only limit for what you can do with this. You could add an FFT subcommand,
matrix math, BLAS, whatever.
This is a fairly complex argument list, and so for this function (and for plshade, described below) we
dispense with trying to exactly mirror the C API, and just concentrate on capturing the functionality
59
Specify pltr1 x y where x and y are 1-d Tcl matrices. In this case pltr1 will be used, and the 1-d
arrays which it needs will be supplied from the Tcl matrices x and y.
Specify pltr2 x y where x and y are 2-d Tcl matrices. In this case pltr2 will be used, and the 2-d
arrays which it needs will be supplied from the Tcl matrices x and y.
Now, there can be no question that this is both more concise and less powerful than what you could
get in C. The loss of the ability to provide a user specified transformation function is regrettable. If you
really do need that functionality, you will have to implement your own Tcl extension command to do
pretty much the same thing as the provided Tcl extension command plcont (which is in tclAPI.c in
function plcontCmd()), except specify the C transformation function of your choice.
However, that having been said, we recognize that one common use for this capability is to provide a
special version of pltr2 which knows how to implement a periodic boundary condition, so that polar
plots, for example, can be implemented cleanly. That is, if you want to draw contours of a polar data set
defined on a 64 x 64 grid, ensuring that contour lines would actually go all the way around the origin
rather than breaking off like a silly pacman figure, then you had basically two choices in C. You could
copy the data to a 65 x 64 grid, and replicate one row of data into the spare slot, and then plot the
larger data set (taking care to replicate the coordinate arrays you passed to pltr2 in the same way),
or you could make a special version of pltr2 which would understand that one of the coordinates was
wrapped, and perform transformations accordingly without actually making you replicate the data.
Since the former option is ugly in general, and hard to do in Tcl in particular, and since the second option
is even more difficult to do in Tcl (requiring you do make a special Tcl extension command as described
above), we provide special, explicit support for this common activity. This is provided through the use
of a new, optional parameter wrap which may be specified as the last parameter to the Tcl command,
only if you are using pltr2. Supplying 1 will wrap in the first coordinate, 2 will wrap in the second
coordinate.
The resultant Tcl command is:
plcont f [kx lx ky ly] clev [pltr x y] [wrap]
Note that the brackets here are used to signify optional arguments, not to represent Tcl command
substitution!
The Tcl demo x09.tcl provides examples of all the capabilities of this interface to contouring from Tcl.
Note in particular, x09_polar which does a polar contour without doing anything complicated in the way
of setup, and without getting a pacman as the output.
60
where nx and ny were dropped since they are inferred from the Tcl matrix z, defined was dropped since
it isnt supported anyway, and plfill was dropped since it was the only valid choice anyway. The pltr
spec and wrap work exactly as described for the Tcl plcont described above.
The Tcl demo x16.tcl contains extensive demonstrations of use, including a shaded polar plot which
connects in the desirable way without requiring special data preparation, again just like for plcont
described previously.
61
62
Introduction to Tcl
The Tool Command Language, or just Tcl (pronounced tickle) is an embeddable script language which
can be used to control a wide variety of applications. Designed by John Ousterhout of UC Berkeley, Tcl
is freely available under the standard Berkeley copyright. Tcl and Tk (described below) are extensively
documented in a new book published by Addison Wesley, entitled Tcl and the Tk toolkit by John
Ousterhout. This book is a must have for those interested in developing powerful extensible applications
with high quality X Windows user interfaces. The discussion in this chapter cannot hope to approach
the level of introduction provided by that book. Rather we will concentrate on trying to convey some
of the excitement, and show the nuts and bolts of using Tcl and some extensions to provide a powerful
and flexible interface to the PLplot library within your application.
Capabilities of Tcl
The mechanics of using Tcl are very straightforward. Basically you just have to include the file tcl.h,
issue some API calls to create a Tcl interpreter, and then evaluate a script file or perform other operations
supported by the Tcl API. Then just link against libtcl.a and off you go.
Having done this, you have essentially created a shell. That is, your program can now execute shell
scripts in the Tcl language. Tcl provides support for basic control flow, variable substitution file i/o
and subroutines. In addition to the builtin Tcl commands, you can define your own subroutines as Tcl
procedures which effectively become new keywords.
But the real power of this approach is to add new commands to the interpreter which are realized by
compiled C code in your application. Tcl provides a straightforward API call which allows you to register
a function in your code to be called whenever the interpreter comes across a specific keyword of your
choosing in the shell scripts it executes.
63
Acquiring Tcl
There are several important sources of info and code for Tcl. Definitely get the book mentioned above.
The Tcl and Tk toolkits are distributed by anonymous ftp at sprite.berkeley.edu:/tcl1. There are
several files in there corresponding to Tcl, Tk, and various forms of documentation. At the time of this
writing, the current versions of Tcl and Tk are 7.3 and 3.6 respectively. Retrieve those files, and install
using the instructions provided therein.
The other major anonymous ftp site for Tcl is harbor.ecn.purdue.edu:/pub/tcl2. Harbor contains a
mirror of sprite as well as innumerable extensions, Tcl/Tk packages, tutorials, documentation, etc. The
level of excitement in the Tcl community is extraordinarily high, and this is reflected by the great plethora
of available, high quality, packages and extensions available for use with Tcl and Tk. Explorethere is
definitely something for everyone.
Additionally there is a newsgroup, comp.lang.tcl which is well read, and an excellent place for people
to get oriented, find help, etc. Highly recommended.
In any event, in order to use the Tk driver in PLplot, you will need Tcl-8.2 and Tk-8.2 (or higher
versions). Additionally, in order to use the extended WISH paradigm (described below) you will need
iTcl-3.1 (or a higher version).
However, you will quite likely find Tcl/Tk to be very addictive, and the great plethora of add-ons available
at harbor will undoubtedly attract no small amount of your attention. It has been our experience that
all of these extensions fit together very well. You will find that there are large sectors of the Tcl user
community which create so-called MegaWishes which combine many of the available extensions into a
single, heavily embellished, shell interpreter. The benefits of this approach will become apparent as you
gain experience with Tcl and Tk.
Introduction to Tk
As mentioned above, Tcl is designed to be extensible. The first and most basic Tcl extension is Tk, an
X11 toolkit. Tk provides the same basic facilities that you may be familiar with from other X11 toolkits
such as Athena and Motif, except that they are provided in the context of the Tcl language. There are
C bindings too, but these are seldom neededthe vast majority of useful Tk applications can be coded
using Tcl scripts.
If it has not become obvious already, it is worth noting at this point that Tcl is one example of a family
of languages known generally as Very High Level Languages, or VHLLs. Essentially a VHLL raises
the level of programming to a very high level, allowing very short token streams to accomplish as much
as would be required by many scores of the more primitive actions available in a basic HLL. Consider,
for example, the basic Hello World! application written in Tcl/Tk.
#!/usr/local/bin/wish -f
button .hello -text "Hello World!"
pack .hello
64
and so forth.
These high level widgets composed of smaller Tk widgets, are known as megawidgets. There is a
developing subculture of the Tcl/Tk community for designing and implementing megawidgets, and [incr
Tcl] is the most popular enabling technology.
In particular, it is the enabling technology which is employed for the construction of the PLplot Tcl
extensions, described below.
65
To access PLplot facilities from their own extended WISH and/or Tcl/Tk user interface scripts.
To have PLplot display its output in a window integrated directly into the rest of their Tcl/Tk interface.
For instance, prior to PLplot 5.0, if a programmer wanted to use PLplot in a Tcl/Tk application, the
best he could manage was to call the PLplot C API from compiled C code, and get the output via the
Xwin driver, which would display in its own toplevel window. In other words, there was no integration,
and the result was pretty sloppy.
With PLplot 5.0, there is now a supported Tcl interface to PLplot functionality. This is provided through
a family of PLplot megawidgets implemented in [incr Tcl]. Using this interface, a programmer can get
a PLplot window/widget into a Tk interface as easily as:
PLWin .plw
pack .plw
WISH Construction
The standard way to make your own WISH, as supported by the Tcl/Tk system, is to take a boilerplate
file, tkAppInit.c, edit to reflect the Tcl/Tk extensions you will be requiring, add some commands to the
interpreter, and link it all together.
Here for example is the important part of the tk02 demo, extracted from the file xtk02.c, which is
effectively the extended WISH definition file for the tk02 demo. Comments and other miscellany are
omitted.
#include "tk.h"
#include "itcl.h"
/* ... */
int
int
66
myplotCmd
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Itcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Pltk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Call Tcl_CreateCommand for application-specific commands, if
* they werent already created by the init procedures called above.
*/
Tcl_CreateCommand(interp, "myplot", myplotCmd,
(ClientData) main, (void (*)(ClientData)) NULL);
/*
* Specify a user-specific startup file to invoke if the
* application is run interactively. Typically the startup
* file is "~/.apprc" where "app" is the name of the application.
* If this line is deleted then no user-specific startup file
* will be run under any conditions.
*/
tcl_RcFileName = "~/.wishrc";
return TCL_OK;
}
/* ... myPlotCmd, etc ... */
67
WISH Linking
Having constructed your Tcl_AppInit() function, you now merely need to link this file with your own
private files to provide the code for any functions you registered via Tcl_CreateCommand() (and any they
depend on), against the Tcl, Tk and extension libraries you are using.
cc -c tkAppInit.c
cc -c mycommands.c
cc -o my_wish tkAppInit.o mycommands.o
-lplplotftk -ltcl -ltk -litcl -lX11 -lm
WISH Programming
Now you are ready to put the genie to work. The basic plan here is to write shell scripts which use your
new application specific windowing shell as their interpreter, to implement X Windows user interfaces
to control and utilize the facilities made available in your extensions.
Effectively this just comes down to writing Tcl/Tk code, embellished as appropriate with calls to the
extension commands you registered. Additionally, since this wish includes the PLplot extensions, you
can instantiate any of the PLplot family of [incr Tcl] classes, and invoke methods on those objects to
effect the drawing of graphs. Similarly, you may have your extension commands (which are coded in C)
call the PLplot C programmers API to draw into the widget. In this way you can have the best of both
worlds. Use compiled C code when the computational demands require the speed of compiled code, or
use Tcl when your programming convenience is more important than raw speed.
Notes
1. ftp://sprite.berkeley.edu/tcl
2. ftp://harbor.ecn.purdue.edu/pub/tcl
68
69
70
There is also a Perl PLplot interface on CPAN2 which is not dependent on PDL. The Perl module is
called Graphics::PLplot3 and is appropriate for small data arrays. The API is very similar to the C
API except that if the number of elements in an array is required by the C function the perl interface
calculates it automatically. Also, return values are returned and not supplied as arguments. Here is the
PDL example above translated to Graphics::PLplot:
use Graphics::PLplot qw/ :all /;
@x = (0..5);
@y = map {$_ * $_} @x;
plsdev ("xwin");
plinit ();
plcol0 (1);
plenv (-0.5, 5.5, -1, 26, 0, 0);
plline (\@x, \@y);
plend ();
Notes
1. http://pdl.perl.org
2. http://www.cpan.org
3. http://search.cpan.org/%7Etjenness/
71
72
73
74
IV. Reference
References
Furnish
G.,
Das
Graphikpaket
PLplot
magazin.de/ausgabe/1996/12/Plplot/plplot.html),
December
(in
German)
Linux
(http://www.linuxMagazin,
1996
Furnish G., Horton W., Kishimoto Y., LeBrun M., Tajima T., Global Gyrokinetic Simulation of Tokamak Transport, Physics of Plasmas, 6, 1, 1999
Irwin A.W., Fukushima T., A Numerical Time Ephemeris of the Earth, Astronomy and Astrophysics,
348, 642, 1999
LeBrun M.J., Tajima T., Gray M., Furnish G., Horton W., Toroidal Effects on Drift-Wave Turbulence,
Physics of Fluids, B5, 752, 1993
77
78
numerical label
pl_setcontlabelparam (offset , size , spacing , active );
pladv (sub );
79
Advances to the next subpage if sub =0, performing a page advance if there are no remaining subpages
on the current page. If subwindowing isnt being used, pladv(0) will always advance the page. If sub >0,
PLplot switches to the specified subpage. Note that this allows you to overwrite a plot on the specified
subpage; if this is not what you intended, use pleop followed by plbop to first advance the page. This
routine is called automatically (with sub =0) by plenv, but if plenv is not used, pladv must be called after
initializing PLplot but before defining the viewport.
sub (PLINT, input)
Specifies the subpage number (starting from 1 in the top left corner and increasing along the rows)
to which to advance. Set to zero to advance to the next subpage.
Draws a box around the currently defined viewport with arbitrary world-coordinate origin specified by
x0 and y0 and labels it with world coordinate values appropriate to the window. Thus plaxes should
only be called after defining both viewport and window. The character strings xopt and yopt specify
how the box should be drawn as described below. If ticks and/or subticks are to be drawn for a particular
axis, the tick intervals and number of subintervals may be specified explicitly, or they may be defaulted
by setting the appropriate arguments to zero.
x0 (PLFLT, input)
World X coordinate of origin.
y0 (PLFLT, input)
World Y coordinate of origin.
xopt (const char *, input)
Pointer to character string specifying options for horizontal axis. The string can include any combination of the following letters (upper or lower case) in any order:
a:
Draws axis, X-axis is horizontal line (y=0), and Y-axis is vertical line (x=0).
b:
c:
f:
g:
h:
i:
Inverts tick marks, so they are drawn outwards, rather than inwards.
l:
Labels axis logarithmically. This only affects the labels, not the data, and so it is necessary to
compute the logarithms of data points before passing them to any of the drawing routines.
m:
Writes numeric labels at major tick intervals in the unconventional location (above box for X,
right of box for Y).
n:
Writes numeric labels at major tick intervals in the conventional location (below box for X,
left of box for Y).
80
t:
Write numeric labels for vertical axis parallel to the base of the graph, rather than parallel to
the axis.
Plots a histogram consisting of nbin bins. The value associated with the ith bin is placed in x [i], and
the number of points in the bin is placed in y [i]. For proper operation, the values in x [i] must form
a strictly increasing sequence. If center =0, x [i] is the left-hand edge of the ith bin, and if center =1,
the bin boundaries are placed midway between the values in the x array. Also see plhist for drawing
histograms from unbinned data.
nbin (PLINT, input)
Number of bins (i.e., number of values in x and y arrays.)
x (PLFLT *, input)
Pointer to array containing values associated with bins. These must form a strictly increasing sequence.
y (PLFLT *, input)
Pointer to array containing number of points in bin. This is a PLFLT (instead of PLINT) array so as
to allow histograms of probabilities, etc.
81
plbop ();
Begins a new page. For a file driver, the output file is opened if necessary. Advancing the page via
pleop and plbop is useful when a page break is desired at a particular point when plotting to subpages.
Another use for pleop and plbop is when plotting pages to different files, since you can manually set the
file name (or file handle) by calling plsfnam or plsfile after the call to pleop (in fact some drivers may
only support a single page per file, making this a necessity). One way to handle this case automatically
is to page advance via pladv, but enable familying (see plsfam) with a small limit on the file size so that
a new family member file will be created on each page break.
Draws a box around the currently defined viewport, and labels it with world coordinate values appropriate to the window. Thus plbox should only be called after defining both viewport and window. The
character strings xopt and yopt specify how the box should be drawn as described below. If ticks and/or
subticks are to be drawn for a particular axis, the tick intervals and number of subintervals may be
specified explicitly, or they may be defaulted by setting the appropriate arguments to zero.
xopt (const char *, input)
Pointer to character string specifying options for horizontal axis. The string can include any combination of the following letters (upper or lower case) in any order:
a:
Draws axis, X-axis is horizontal line (y=0), and Y-axis is vertical line (x=0).
b:
c:
f:
g:
h:
i:
Inverts tick marks, so they are drawn outwards, rather than inwards.
l:
Labels axis logarithmically. This only affects the labels, not the data, and so it is necessary to
compute the logarithms of data points before passing them to any of the drawing routines.
m:
Writes numeric labels at major tick intervals in the unconventional location (above box for X,
right of box for Y).
n:
Writes numeric labels at major tick intervals in the conventional location (below box for X,
left of box for Y).
82
t:
Write numeric labels for vertical axis parallel to the base of the graph, rather than parallel to
the axis.
plbox3 (xopt , xlabel , xtick , nxsub , yopt , ylabel , ytick , nysub , zopt , zlabel , ztick ,
nzsub );
Draws axes, numeric and text labels for a three-dimensional surface plot. For a more complete description
of three-dimensional plotting see the Section called Three Dimensional Surface Plots in Chapter 3.
xopt (const char *, input)
Pointer to character string specifying options for the x axis. The string can include any combination
of the following letters (upper or lower case) in any order:
b:
Draws axis at base, at height z=zmin where zmin is defined by call to plw3d. This character
must be specified in order to use any of the other options.
f:
i:
Inverts tick marks, so they are drawn downwards, rather than upwards.
l:
Labels axis logarithmically. This only affects the labels, not the data, and so it is necessary to
compute the logarithms of data points before passing them to any of the drawing routines.
n:
s:
t:
u:
If this is specified, the text label for the axis is written under the axis.
83
c:
d:
Draws grid lines parallel to the x-y plane behind the figure. These lines are not drawn until
after plot3d or plmesh are called because of the need for hidden line removal.
f:
i:
Inverts tick marks, so they are drawn away from the center.
l:
Labels axis logarithmically. This only affects the labels, not the data, and so it is necessary to
compute the logarithms of data points before passing them to any of the drawing routines.
84
m:
Writes numeric labels at major tick intervals on the right-hand vertical axis.
n:
Writes numeric labels at major tick intervals on the left-hand vertical axis.
s:
t:
u:
If this is specified, the text label is written beside the left-hand axis.
v:
If this is specified, the text label is written beside the right-hand axis.
Calculate world coordinates, wx and wy , and corresponding window index from relative device coordinates,
rx and ry .
rx (PLFLT, input)
Input relative device coordinate (ranging from 0. to 1.) for the x coordinate.
ry (PLFLT, input)
Input relative device coordinate (ranging from 0. to 1.) for the y coordinate.
wx (PLFLT *, output)
Pointer to the returned world coordinate for x corresponding to the relative device coordinates rx
and ry .
wy (PLFLT *, output)
Pointer to the returned world coordinate for y corresponding to the relative device coordinates rx
and ry .
window (PLINT *, output)
Pointer to the returned last defined window index that corresponds to the input relative device
coordinates (and the returned world coordinates). To give some background on the window index,
for each page the initial window index is set to zero, and each time plwind is called within the
page, world and device coordinates are stored for the window and the window index is incremented.
Thus, for a simple page layout with non-overlapping viewports and one window per viewport, window
corresponds to the viewport index (in the order which the viewport/windows were created) of the
only viewport/window corresponding to rx and ry . However, for more complicated layouts with
potentially overlapping viewports and possibly more than one window (set of world coordinates) per
viewport, window and the corresponding output world coordinates corresponds to the last window
created that fulfils the criterion that the relative device coordinates are inside it. Finally, in all cases
where the input relative device coordinates are not inside any viewport/window, then window is set
to -1.
85
plclear ();
Clears the current page, effectively erasing everything that have been drawn. This command only works
with interactive drivers; if the driver does not support this, the page is filled with the background color
in use. If the current page is divided into subpages, only the current subpage is erased. The nth subpage
can be selected with pladv(n).
plclr ();
Deprecated. Use the new name, pleop, for this function instead.
plcol (color );
Deprecated. Use the new name, plcol0, for this function instead.
color (PLINT, input)
See plcol0.
plcol0 (color );
Sets the color for color map0 (see the Section called Color Map0 in Chapter 3).
color (PLINT, input)
Integer representing the color. The defaults at present are (these may change):
0 black (default background)
1 red (default foreground)
2 yellow
3 green
4 aquamarine
5 pink
6 wheat
7 grey
8 brown
9 blue
10 BlueViolet
11 cyan
12 turquoise
13 magenta
86
salmon
white
Use plscmap0 to change the entire map0 color palette and plscol0 to change an individual color in the
map0 color palette.
plcol1 (col1 );
Sets the color for color map1 (see the Section called Color Map1 in Chapter 3).
col1 (PLFLT, input)
This value must be in the range from 0. to 1. and is mapped to color using the continuous map1
color palette which by default ranges from blue to the background color to red. The map1 palette
can also be straightforwardly changed by the user with plscmap1 or plscmap1l.
Draws a contour plot of the data in z [nx ][ny ], using the nlevel contour levels specified by clevel .
Only the region of the array from kx to lx and from ky to ly is plotted out. A transformation routine
pointed to by pltr with a pointer pltr_data for additional data required by the transformation routine
is used to map indices within the array to the world coordinates. See the following discussion of the
arguments and the Section called Contour and Shade Plots in Chapter 3 for more information.
z (PLFLT **, input)
Pointer to a vectored two-dimensional array containing data to be contoured.
nx, ny (PLINT, input)
Physical dimensions of array z .
kx, lx (PLINT, input)
Range of x indices to consider.
ky, ly (PLINT, input)
Range of y indices to consider.
clevel (PLFLT *, input)
Pointer to array specifying levels at which to draw contours.
nlevel (PLINT, input)
Number of contour levels to draw.
pltr (void (*) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer) , input)
Pointer to function that defines transformation between indices in array z and the world coordinates
(C only). Transformation functions are provided in the PLplot library: pltr0 for identity mapping,
and pltr1 and pltr2 for arbitrary mappings respectively defined by one- and two-dimensional arrays.
In addition, user-supplied routines for the transformation can be used as well. Examples of all of these
87
plcpstrm: Copy state parameters from the reference stream to the current stream
Copies state parameters from the reference stream to the current stream. Tell driver interface to map
device coordinates unless flags == 1.
This function is used for making save files of selected plots (e.g. from the TK driver). After initializing,
you can get a copy of the current plot to the specified device by switching to this stream and issuing
a plcpstrm and a plreplot, with calls to plbop and pleop as appropriate. The plot buffer must have
previously been enabled (done automatically by some display drivers, such as X).
iplsr (PLINT, input)
Number of reference stream.
flags (PLINT, input)
If flags is set to 1 the device coordinates are not copied from the reference to current stream.
plend ();
Ends a plotting session, tidies up all the output files, switches interactive devices back into text mode
and frees up any memory that was allocated. Must be called before end of program.
plend1 ();
Ends a plotting session for the current output stream only. See plsstrm for more info.
plenv0: Same as plenv but if in multiplot mode does not advance the subpage,
88
the scales will not be set, the user must set up the scale before calling plenv0 using plsvpa,
plvasp or other.
0:
the x and y axes are scaled independently to use as much of the screen as possible.
1:
2:
the axis of the x and y axes are made equal, and the plot box will be square.
-1:
0:
1:
2:
3:
10:
same as 0 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
11:
same as 1 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
12:
same as 2 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
13:
same as 3 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
20:
same as 0 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
21:
same as 1 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
89
same as 2 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
23:
same as 3 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
30:
same as 0 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
31:
same as 1 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
32:
same as 2 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
33:
same as 3 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
Sets up plotter environment for simple graphs by calling pladv and setting up viewport and window to
sensible default values. plenv leaves enough room around most graphs for axis labels and a title. When
these defaults are not suitable, use the individual routines plvpas, plvpor, or plvasp for setting up the
viewport, plwind for defining the window, and plbox for drawing the box.
xmin (PLFLT, input)
Value of x at left-hand edge of window (in world coordinates).
xmax (PLFLT, input)
Value of x at right-hand edge of window (in world coordinates).
ymin (PLFLT, input)
Value of y at bottom edge of window (in world coordinates).
ymax (PLFLT, input)
Value of y at top edge of window (in world coordinates).
just (PLINT, input)
Controls how the axes will be scaled:
-1:
the scales will not be set, the user must set up the scale before calling plenv using plsvpa,
plvasp or other.
0:
the x and y axes are scaled independently to use as much of the screen as possible.
1:
2:
the axis of the x and y axes are made equal, and the plot box will be square.
90
0:
1:
2:
3:
10:
same as 0 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
11:
same as 1 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
12:
same as 2 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
13:
same as 3 except logarithmic x tick marks. (The x data have to be converted to logarithms
separately.)
20:
same as 0 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
21:
same as 1 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
22:
same as 2 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
23:
same as 3 except logarithmic y tick marks. (The y data have to be converted to logarithms
separately.)
30:
same as 0 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
31:
same as 1 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
32:
same as 2 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
33:
same as 3 except logarithmic x and y tick marks. (The x and y data have to be converted to
logarithms separately.)
pleop ();
Clears the graphics screen of an interactive device, or ejects a page on a plotter. See plbop for more
information.
91
Draws a set of n vertical error bars, the ith error bar extending from ymin [i] to ymax [i] at x coordinate
x [i]. The terminals of the error bar are of length equal to the minor tick length (settable using plsmin).
n (PLINT, input)
Number of error bars to draw.
x (PLFLT *, input)
Pointer to array with x coordinates of error bars.
ymin (PLFLT *, input)
Pointer to array with y coordinates of lower endpoint of error bars.
ymax (PLFLT *, input)
Pointer to array with y coordinate of upper endpoint of error bar.
plfamadv: Advance to the next family file on the next new page
plfamadv ();
plfill (n , x , y );
92
plfill3 (n , x , y , z );
Fills the 3D polygon defined by the n points in the x , y , and z arrays using the pattern defined by
plpsty or plpat. The routine will automatically close the polygon between the last and first vertices. If
multiple closed polygons are passed in x , y , and z then plfill3 will fill in between them.
n (PLINT, input)
Number of vertices in polygon.
x (PLFLT *, input)
Pointer to array with x coordinates of vertices.
y (PLFLT *, input)
Pointer to array with y coordinates of vertices.
z (PLFLT *, input)
Pointer to array with z coordinates of vertices.
plflush ();
plfont (font );
Sets the default character font for subsequent character drawing. Also affects symbols produced by
plpoin. This routine has no effect unless the extended character set is loaded (see plfontld).
93
2:
Roman font
3:
Italic font
4:
Script font
plfontld (set );
Sets the character set to use for subsequent character drawing. May be called before calling initializing
PLplot.
set (PLINT, input)
Specifies the character set to load:
0:
1:
plgcol0: Returns 8-bit RGB values for given color from color map0
plgcol0 (icol0 , r , g , b );
Returns 8-bit RGB values (-255) for given color from color map0 (see the Section called Color Map0 in
Chapter 3). Values are negative if an invalid color id is given.
icol0 (PLINT, input)
Index of desired cmap0 color.
94
plgcolbg (r , g , b );
plgcompression (compression );
Get the current device-compression setting. This parameter is only used for drivers that provide compression.
compression (PLINT *, output)
Pointer to a variable to be filled with the current device-compression setting.
plgdev (p_dev );
Get the current device (keyword) name. Note: you must have allocated space for this (80 characters is
safe).
p_dev (char *, output)
Pointer to device (keyword) name string.
95
Get relative margin width, aspect ratio, and relative justification that define current device-space window.
If plsdidev has not been called the default values pointed to by p_mar , p_aspect , p_jx , and p_jy will
all be 0.
p_mar (PLFLT *, output)
Pointer to relative margin width.
p_aspect (PLFLT *, output)
Pointer to aspect ratio.
p_jx (PLFLT *, output)
Pointer to relative justification in x.
p_jy (PLFLT *, output)
Pointer to relative justification in y.
plgdiori (p_rot );
Get plot orientation parameter which is multiplied by 90 to obtain the angle of rotation. Note, arbitrary
rotation parameters such as 0.2 (corresponding to 18 ) are possible, but the usual values for the rotation
parameter are 0., 1., 2., and 3. corresponding to 0 (landscape mode), 90 (portrait mode), 180 (seascape
mode), and 270 (upside-down mode). If plsdiori has not been called the default value pointed to by
p_rot will be 0.
p_rot (PLFLT *, output)
Pointer to orientation parameter.
Get relative minima and maxima that define current plot-space window. If plsdiplt has not been called
the default values pointed to by p_xmin , p_ymin , p_xmax , and p_ymax will be 0., 0., 1., and 1.
p_xmin (PLFLT *, output)
Pointer to relative minimum in x.
p_ymin (PLFLT *, output)
Pointer to relative minimum in y.
96
Gets information about current family file, if familying is enabled. See the Section called Family File
Output in Chapter 3 for more information.
fam (PLINT *, output)
Pointer to variable with the Boolean family flag value. If nonzero, familying is enabled.
num (PLINT *, output)
Pointer to variable with the current family file number.
bmax (PLINT *, output)
Pointer to variable with the maximum file size (in bytes) for a family file.
plgfnam (fnam );
plglevel (p_level );
0, uninitialized
1, initialized
2, viewport defined
97
Gets the current page configuration. The parameters are expressed in units that are specific to the
current driver. For instance: screen drivers will usually interpret them as number of pixels, whereas
printer drivers will usually use mm.
xp (PLFLT *, output)
Pointer to number of pixels in x.
yp (PLFLT *, output)
Pointer to number of pixels in y.
xleng (PLINT *, output)
Pointer to x page length value.
yleng (PLINT *, output)
Pointer to y page length value.
xoff (PLINT *, output)
Pointer to x page offset.
yoff (PLINT *, output)
Pointer to y page offset.
plgra ();
Sets an interactive device to graphics mode, used in conjunction with pltext to allow graphics and text
to be interspersed. On a device which supports separate text and graphics windows, this command causes
control to be switched to the graphics window. If already in graphics mode, this command is ignored.
It is also ignored on devices which only support a single window or use a different method for shifting
focus. See also pltext.
Real world data is frequently irregularly sampled, but all PLplot 3D plots require data placed in a
uniform grid. This function takes irregularly sampled data from three input arrays x[npts], y[npts],
98
GRID_DTLI:
GRID_NNI:
GRID_NNIDW:
GRID_NNLI:
GRID_NNAIDW:
specifies the number of neighbors to use, the lower the value, the noisier (more
local) the approximation is.
99
specifies what a thin triangle is, in the range [1. .. 2.]. High values enable the
usage of very thin triangles for interpolation, possibly resulting in error in the approximation.
GRID_NNI,
only weights greater than data will be accepted. If 0, all weigths will be accepted.
Gets the size of the current subpage in millimeters measured from the bottom left hand corner of the
output device page or screen. Can be used in conjunction with plsvpa for setting the size of a viewport
in absolute coordinates (millimeters).
xmin (PLFLT *, output)
Pointer to variable with position of left hand edge of subpage in millimeters.
xmax (PLFLT *, output)
Pointer to variable with position of right hand edge of subpage in millimeters.
ymin (PLFLT *, output)
Pointer to variable with position of bottom edge of subpage in millimeters.
ymax (PLFLT *, output)
Pointer to variable with position of top edge of subpage in millimeters.
plgstrm (strm );
Gets the number of the current output stream. See also plsstrm.
strm (PLINT *, output)
Pointer to current stream value.
plgver (p_ver );
Get the current library version number. Note: you must have allocated space for this (80 characters is
safe).
p_ver (char *, output)
Pointer to the current library version number.
100
Returns current values of the digmax and digits flags for the x axis. digits is updated after the plot
is drawn, so this routine should only be called after the call to plbox (or plbox3) is complete. See the
Section called Annotating the Viewport in Chapter 3 for more information.
101
Identical to plgxax, except that arguments are flags for y axis. See the description of plgxax for more
detail.
digmax (PLINT *, output)
Pointer to variable with the maximum number of digits for the y axis. If nonzero, the printed label
has been switched to a floating point representation when the number of digits exceeds digmax .
digits (PLINT *, output)
Pointer to variable with the actual number of digits for the numeric labels (y axis) from the last
plot.
Identical to plgxax, except that arguments are flags for z axis. See the description of plgxax for more
detail.
digmax (PLINT *, output)
Pointer to variable with the maximum number of digits for the z axis. If nonzero, the printed label
has been switched to a floating point representation when the number of digits exceeds digmax .
digits (PLINT *, output)
Pointer to variable with the actual number of digits for the numeric labels (z axis) from the last
plot.
Plots a histogram from n data points stored in the array data . This routine bins the data into nbin bins
equally spaced between datmin and datmax , and calls plbin to draw the resulting histogram. Parameter
102
plhls (h , l , s );
Set current color by hue, lightness, and saturation. Convert hls color coordinates to rgb, then call plrgb.
Do not use this. Only retained for backward compatibility. Use plHLS_RGB and plscol0 instead.
h (PLFLT, input)
NEEDS DOCUMENTATION
l (PLFLT, input)
NEEDS DOCUMENTATION
s (PLFLT, input)
NEEDS DOCUMENTATION
103
plinit ();
Initializing the plotting package. The program prompts for the device keyword or number of the desired
output device. Hitting a RETURN in response to the prompt is the same as selecting the first device.
plinit will issue no prompt if either the device was specified previously (via command line flag, the
plsetopt function, or the plsdev function), or if only one device is enabled when PLplot is installed. If
subpages have been specified, the output device is divided into nx by ny sub-pages, each of which may be
used independently. If plinit is called again during a program, the previously opened file will be closed.
The subroutine pladv is used to advance from one subpage to the next.
pljoin (x1 , y1 , x2 , y2 );
104
Routine for writing simple labels. Use plmtex for more complex labels.
xlabel (const char *, input)
Label for horizontal axis.
ylabel (const char *, input)
Label for vertical axis.
tlabel (const char *, input)
Title of graph.
pllightsource (x , y , z );
Sets the 3D position of the light source for use with plsurf3d.
x (PLFLT, input)
X-coordinate of the light source.
y (PLFLT, input)
Y-coordinate of the light source.
z (PLFLT, input)
Z-coordinate of the light source.
plline (n , x , y );
105
plline3 (n , x , y , z );
Draws line in 3 space defined by n points in x , y , and z . You must first set up the viewport, the 2d
viewing window (in world coordinates), and the 3d normalized coordinate box. See x18c.c for more info.
n (PLINT, input)
Number of points defining line.
x (PLFLT *, input)
Pointer to array with x coordinates of points.
y (PLFLT *, input)
Pointer to array with y coordinates of points.
z (PLFLT *, input)
Pointer to array with z coordinates of points.
pllsty (n );
This sets the line style according to one of eight predefined patterns (also see plstyl).
n (PLINT, input)
Integer value between 1 and 8. Line style 1 is a continuous line, line style 2 is a line with short
dashes and gaps, line style 3 is a line with long dashes and gaps, line style 4 has long dashes and
short gaps and so on.
plmesh (x , y , z , nx , ny , opt );
Plots a surface mesh within the environment set up by plw3d. The surface is defined by the twodimensional array z [nx ][ny ], the point z [i][j] being the value of the function at (x [i], y [j]). Note
that the points in arrays x and y do not need to be equally spaced, but must be stored in ascending
order. The parameter opt controls the way in which the surface is displayed. For further details see the
Section called Three Dimensional Surface Plots in Chapter 3.
x (PLFLT *, input)
Pointer to set of x coordinate values at which the function is evaluated.
y (PLFLT *, input)
Pointer to set of y coordinate values at which the function is evaluated.
106
opt =DRAW_LINEY:
opt =DRAW_LINEXY:
Identical to plmesh but with extra functionalities: the surface mesh can be colored accordingly to the
current z value being plotted, a contour plot can be drawn at the base XY plane, and a curtain can be
drawn between the plotted function border and the base XY plane.
x (PLFLT *, input)
Pointer to set of x coordinate values at which the function is evaluated.
y (PLFLT *, input)
Pointer to set of y coordinate values at which the function is evaluated.
z (PLFLT **, input)
Pointer to a vectored two-dimensional array with set of function values.
nx (PLINT, input)
Number of x values at which function is evaluated.
ny (PLINT, input)
Number of y values at which function is evaluated.
opt (PLINT, input)
Determines the way in which the surface is represented. To specify more than one option just add
the options, e.g. DRAW_LINEXY + MAG_COLOR
opt =DRAW_LINEX:
opt =DRAW_LINEY:
opt =DRAW_LINEXY:
opt =MAG_COLOR:
Each line in the mesh is colored according to the z value being plotted. The color
is used from the current colormap 1.
107
A contour plot is drawn at the base XY plane using parameters nlevel and
clevel .
opt =DRAW_SIDES:
draws a curtain between the base XY plane and the borders of the plotted
function.
clevel (PLFLT *, input)
Pointer to the array that defines the contour level spacing.
nlevel (PLINT, input)
Number of elements in the clevel array.
plmkstrm (p_strm );
Creates a new stream and makes it the default. Differs from using plsstrm, in that a free stream number
is found, and returned. Unfortunately, I have to start at stream 1 and work upward, since stream 0 is
preallocated. One of the big flaws in the PLplot API is that no initial, library-opening call is required.
So stream 0 must be preallocated, and there is no simple way of determining whether it is already in
use or not.
p_strm (PLINT *, output)
Pointer to stream number of the created stream.
Writes text at a specified position relative to the viewport boundaries. Text may be written inside or
outside the viewport, but is clipped at the subpage boundaries. The reference point of a string lies along
a line passing through the string at half the height of a capital letter. The position of the reference point
along this line is determined by just , and the position of the reference point relative to the viewport is
set by disp and pos .
side (const char *, input)
Specifies the side of the viewport along which the text is to be written. The string must be one of:
b:
bv:
l:
lv:
r:
108
rv:
t:
Plots a three dimensional surface plot within the environment set up by plw3d. The surface is defined
by the two-dimensional array z [nx ][ny ], the point z [i][j] being the value of the function at (x [i],
y [j]). Note that the points in arrays x and y do not need to be equally spaced, but must be stored
in ascending order. The parameter opt controls the way in which the surface is displayed. For further
details see the Section called Three Dimensional Surface Plots in Chapter 3. The only difference between
plmesh and plot3d is that plmesh draws the botton side of the surface, while plot3d only draws the surface
as viewed from the top.
x (PLFLT *, input)
Pointer to set of x coordinate values at which the function is evaluated.
y (PLFLT *, input)
Pointer to set of y coordinate values at which the function is evaluated.
z (PLFLT **, input)
Pointer to a vectored two-dimensional array with set of function values.
nx (PLINT, input)
Number of x values at which function is evaluated.
ny (PLINT, input)
Number of y values at which function is evaluated.
opt (PLINT, input)
Determines the way in which the surface is represented:
opt =DRAW_LINEX:
opt =DRAW_LINEY:
opt =DRAW_LINEXY:
109
Identical to plot3d but with extra functionalities: the surface mesh can be colored accordingly to the
current z value being plotted, a contour plot can be drawn at the base XY plane, and a curtain can
be drawn between the plotted function border and the base XY plane. The arguments are identical to
plmeshc. The only difference between plmeshc and plot3dc is that plmeshc draws the botton side of the
surface, while plot3dc only draws the surface as viewed from the top.
plpage ();
Deprecated. Use the new name, plbop, for this function instead.
Sets the area fill pattern. The pattern consists of 1 or 2 sets of parallel lines with specified inclinations
and spacings. The arguments to this routine are the number of sets to use (1 or 2) followed by two
pointers to integer arrays (of 1 or 2 elements) specifying the inclinations in tenths of a degree and the
spacing in micrometers. (also see plpsty)
nlin (PLINT, input)
Number of sets of lines making up the pattern, either 1 or 2.
inc (PLINT *, input)
Pointer to array with nlin elements. Specifies the line inclination in tenths of a degree. (Should be
between -900 and 900).
del (PLINT *, input)
Pointer to array with nlin elements. Specifies the spacing in micrometers between the lines making
up the pattern.
plpoin (n , x , y , code );
110
Marks a set of n points in x and y using the symbol defined by code . If code is between 32 and 127, the
symbol is simply the corresponding printable ASCII character in the default font.
n (PLINT, input)
Number of points to be marked.
x (PLFLT *, input)
Pointer to array with x coordinates of the points.
y (PLFLT *, input)
Pointer to array with y coordinates of the points.
code (PLINT, input)
Code number for the symbol to be plotted.
plpoin3 (n , x , y , z , code );
Marks a set of n points in x , y , and z using the symbol defined by code . If code is between 32 and 127,
the symbol is simply the corresponding printable ASCII character in the default font. Setup similar to
plline3.
n (PLINT, input)
Number of points to be marked.
x (PLFLT *, input)
Pointer to array with x coordinates of the points.
y (PLFLT *, input)
Pointer to array with y coordinates of the points.
z (PLFLT *, input)
Pointer to array with z coordinates of the points.
code (PLINT, input)
Code number for the symbol to be plotted.
Draws a polygon in 3 space defined by n points in x , y , and z . Setup like plline3, but differs from that
function in that plpoly3 attempts to determine if the polygon is viewable depending on the order of the
points within the arrays and the value of ifcc . If the back of polygon is facing the viewer, then it isnt
drawn. If this isnt what you want, then use plline3 instead.
111
Sets the number of places after the decimal point in numeric labels.
set (PLINT, input)
If set is equal to 0 then PLplot automatically determines the number of places to use after the
decimal point in numeric labels (like those used to label axes). If set is 1 then prec sets the number
of places.
prec (PLINT, input)
The number of characters to draw after the decimal point in numeric labels.
plpsty (n );
Select one of eight predefined area fill patterns to use (also see plpat).
112
Writes text at a specified position and inclination within the viewport. Text is clipped at the viewport
boundaries. The reference point of a string lies along a line passing through the string at half the height
of a capital letter. The position of the reference point along this line is determined by just , the reference
point is placed at world coordinates (x , y ) within the viewport. The inclination of the string is specified
in terms of differences of world coordinates making it easy to write text parallel to a line in a graph.
x (PLFLT, input)
x coordinate of reference point of string.
y (PLFLT, input)
y coordinate of reference point of string.
dx (PLFLT, input)
Together with dy , this specifies the inclination of the string. The baseline of the string is parallel to
a line joining (x , y ) to (x +dx , y +dy ).
dy (PLFLT, input)
Together with dx , this specifies the inclination of the string.
just (PLFLT, input)
Specifies the position of the string relative to its reference point. If just =0, the reference point is
at the left and if just =1, it is at the right of the string. Other values of just give intermediate
justifications.
text (const char *, input)
The string to be written out.
plreplot ();
plrgb (r , g , b );
113
plrgb1 (r , g , b );
Set line color by 8-bit RGB values. Do not use this. Only retained for backward compatibility. Use the
function plscol0 instead.
r (PLINT, input)
NEEDS DOCUMENTATION
g (PLINT, input)
NEEDS DOCUMENTATION
b (PLINT, input)
NEEDS DOCUMENTATION
This sets up the size of all subsequent characters drawn. The actual height of a character is the product
of the default character size and a scaling factor.
def (PLFLT, input)
The default height of a character in millimeters, should be set to zero if the default height is to
remain unchanged.
scale (PLFLT, input)
Scale factor to be applied to default to get actual character height.
plscmap0 (r , g , b , ncol0 );
114
plscmap0n (ncol0 );
Set number of colors in color map0 (see the Section called Color Map0 in Chapter 3). Allocate (or
reallocate) color map0, and fill with default values for those colors not previously allocated. The first 16
default colors are given in the plcol0 documentation. For larger indices the default color is red.
The drivers are not guaranteed to support more than 16 colors.
ncol0 (PLINT, input)
Number of colors that will be allocated in the map0 palette. If this number is zero or less, then
the value from the previous call to plscmap0n is used and if there is no previous call, then a default
value is used.
plscmap1 (r , g , b , ncol1 );
Set color map1 colors using 8-bit RGB values (see the Section called Color Map1 in Chapter 3). This
also sets the number of colors.
r (PLINT *, input)
Pointer to array with set of unsigned 8-bit integers (0-255) representing the degree of red in the
color.
g (PLINT *, input)
Pointer to array with set of unsigned 8-bit integers (0-255) representing the degree of green in the
color.
115
Set color map1 colors using a piece-wise linear relationship between position in the color map (from 0
to 1) and position in HLS or RGB color space (see the Section called Color Map1 in Chapter 3). May
be called at any time.
The idea here is to specify a number of control points that define the mapping between palette 1 input
positions (intensities) and HLS (or RGB). Between these points, linear interpolation is used which gives
a smooth variation of color with input position. Any number of control points may be specified, located
at arbitrary positions, although typically 2 - 4 are enough. Another way of stating this is that we are
traversing a given number of lines through HLS (or RGB) space as we move through color map1 entries.
The control points at the minimum and maximum position (0 and 1) must always be specified. By
adding more control points you can get more variation. One good technique for plotting functions that
vary about some expected average is to use an additional 2 control points in the center (position ~=
0.5) that are the same lightness as the background (typically white for paper output, black for crt), and
same hue as the boundary control points. This allows the highs and lows to be very easily distinguished.
Each control point must specify the position in color map1 as well as three coordinates in HLS or RGB
space. The first point must correspond to position = 0, and the last to position = 1.
The hue is interpolated around the "front" of the color wheel (red<->green<->blue<->red) unless the
"rev" flag is set, in which case interpolation (between the i and i + 1 control point for rev[i]) proceeds
around the back (reverse) side. Specifying rev=NULL is equivalent to setting rev[]=0 for every control
point.
Table 16-1. Bounds on coordinates
RGB
RGB
RGB
HLS
HLS
HLS
116
R
G
B
hue
lightness
saturation
[0, 1]
[0, 1]
[0, 1]
[0, 360]
[0, 1]
[0, 1]
magnitude
magnitude
magnitude
degrees
magnitude
magnitude
plscmap1n (ncol1 );
Set number of colors in color map1, (re-)allocate color map1, and set default values if this is the first
allocation (see the Section called Color Map1 in Chapter 3).
ncol1 (PLINT, input)
Number of colors that will be allocated in the map1 palette. If this number is zero or less, then
the value from the previous call to plscmap1n is used and if there is no previous call, then a default
value is used.
plscol0: Set a given color from color map0 by 8 bit RGB value
plscol0 (icol0 , r , g , b );
Set a given color by 8-bit RGB value for color map0 (see the Section called Color Map0 in Chapter
3). Overwrites the previous color value for the given index and, thus, does not result in any additional
allocation of space for colors.
icol0 (PLINT, input)
Color index. Must be less than the maximum number of colors (which is set by default, by plscmap0n,
or even by plscmap0).
r (PLINT, input)
Unsigned 8-bit integer (0-255) representing the degree of red in the color.
g (PLINT, input)
Unsigned 8-bit integer (0-255) representing the degree of green in the color.
117
plscolbg (r , g , b );
Set the background color (color 0 in color map 0) by 8-bit RGB value (see the Section called Color Map0
in Chapter 3).
r (PLINT, input)
Unsigned 8-bit integer (0-255) representing the degree of red in the color.
g (PLINT, input)
Unsigned 8-bit integer (0-255) representing the degree of green in the color.
b (PLINT, input)
Unsigned 8-bit integer (0-255) representing the degree of blue in the color.
plscolor (color );
Used to globally turn color output on/off for those drivers/devices that support it.
color (PLINT, input)
Color flag (Boolean). If zero, color is turned off. If non-zero, color is turned on.
plscompression (compression );
Set device-compression level. Only used for drivers that provide compression. This function, if used,
should be invoked before a call to plinit.
compression (PLINT, input)
The desired compression level. This is a device-dependent value.
plsdev (devname );
118
Set relative margin width, aspect ratio, and relative justification that define current device-space window.
If you want to just use the previous value for any of these, just pass in the magic value PL_NOTSET.
It is unlikely that one should ever need to change the aspect ratio but its in there for completeness. If
plsdidev is not called the default values of mar , jx , and jy are all 0. aspect is set to a device-specific
value.
mar (PLFLT, input)
Relative margin width.
aspect (PLFLT, input)
Aspect ratio.
jx (PLFLT, input)
Relative justification in x.
jy (PLFLT, input)
Relative justification in y.
Set up transformation from metafile coordinates. The size of the plot is scaled so as to preserve aspect
ratio. This isnt intended to be a general-purpose facility just yet (not sure why the user would need it,
for one).
dimxmin (PLINT, input)
NEEDS DOCUMENTATION
dimxmax (PLINT, input)
NEEDS DOCUMENTATION
dimymin (PLINT, input)
NEEDS DOCUMENTATION
dimymax (PLINT, input)
NEEDS DOCUMENTATION
119
plsdiori (rot );
Set plot orientation parameter which is multiplied by 90 to obtain the angle of rotation. Note, arbitrary
rotation parameters such as 0.2 (corresponding to 18 ) are possible, but the usual values for the rotation
parameter are 0., 1., 2., and 3. corresponding to 0 (landscape mode), 90 (portrait mode), 180 (seascape
mode), and 270 (upside-down mode). If plsdiori is not called the default value of rot is 0.
rot (PLFLT, input)
Plot orientation parameter.
Set relative minima and maxima that define the current plot-space window. If plsdiplt is not called the
default values of xmin , ymin , xmax , and ymax are 0., 0., 1., and 1.
xmin (PLFLT, input)
Relative minimum in x.
ymin (PLFLT, input)
Relative minimum in y.
xmax (PLFLT, input)
Relative maximum in x.
ymax (PLFLT, input)
Relative maximum in y.
plot-space window
plsdiplz (xmin , ymin , xmax , ymax );
Set relative minima and maxima incrementally (zoom mode) that define the current plot-space window.
This function has the same effect as plsdiplt if that function has not been previously called. Otherwise,
this function implements zoom mode using the transformation min_used = old_min + old_length*min
120
plsesc (esc );
Set the escape character for text strings. From C (in contrast to fortran, see plsescfortran) you pass
esc as a character. Only selected characters are allowed to prevent the user from shooting himself in the
foot (For example, a \ isnt allowed since it conflicts with Cs use of backslash as a character escape).
Here are the allowed escape characters and their corresponding decimal ASCII values:
!, ASCII 33
#, ASCII 35
$, ASCII 36
%, ASCII 37
&, ASCII 38
*, ASCII 42
@, ASCII 64
^, ASCII 94
~, ASCII 126
Set any command-line option internally from a program before it invokes plinit. opt is the name of the
command-line option and optarg is the corresponding command-line option argument.
121
Sets variables dealing with output file familying. Does nothing if familying not supported by the driver.
This routine, if used, must be called before initializing PLplot. See the Section called Family File Output
in Chapter 3 for more information.
fam (PLINT, input)
Family flag (Boolean). If nonzero, familying is enabled.
num (PLINT, input)
Current family file number.
bmax (PLINT, input)
Maximum file size (in bytes) for a family file.
plsfnam (fnam );
Sets the current output file name, if applicable. If the file name has not been specified and is required by
the driver, the user will be prompted for it. If using the X-windows output driver, this sets the display
name. This routine, if used, must be called before initializing PLplot.
fnam (const char *, input)
Pointer to file name string.
Shade regions on the basis of value. This is the high-level routine for making continuous color shaded
plots with cmap1 while plshade (or plshade1) are used for individual shaded regions using either cmap0
or cmap1. examples/c/x16c.c shows a number of examples for using this function. See the following
discussion of the arguments and the Section called Contour and Shade Plots in Chapter 3 for more
information.
122
123
Shade individual region on the basis of value. Use plshades if you want to shade a number of regions
using continuous colors. plshade is identical to plshade1 except for the type of the first parameter. See
plshade1 for further discussion.
a (PLFLT **, input)
nx (PLINT, input)
ny (PLINT, input)
124
Shade individual region on the basis of value. Use plshades if you want to shade a number of contiguous
regions using continuous colors. In particular the edge contours are treated properly in plshades. If you
attempt to do contiguous regions with plshade1 (or plshade) the contours at the edge of the shade are
partially obliterated by subsequent plots of contiguous shaded regions. plshade1 differs from plshade
by the type of the first argument. Look at the argument list below, plcont and the Section called
Contour and Shade Plots in Chapter 3 for more information about the transformation from grid to
125
126
This sets up the length of the major ticks. The actual length is the product of the default length and a
scaling factor as for character height.
def (PLFLT, input)
The default length of a major tick in millimeters, should be set to zero if the default length is to
remain unchanged.
scale (PLFLT, input)
Scale factor to be applied to default to get actual tick length.
127
Set the memory area to be plotted (with the mem driver) as the dev member of the stream structure.
Also set the number of pixels in the memory passed in plotmem , which is a block of memory maxy by
maxx by 3 bytes long, say: 480 x 640 x 3 (Y, X, RGB)
This memory will have to be freed by the user!
maxx (PLINT, input)
Size of memory area in the X coordinate.
maxy (PLINT, input)
Size of memory area in the Y coordinate.
plotmem (void *, input)
Pointer to the beginning of the user-supplied memory area.
This sets up the length of the minor ticks and the length of the terminals on error bars. The actual
length is the product of the default length and a scaling factor as for character height.
def (PLFLT, input)
The default length of a minor tick in millimeters, should be set to zero if the default length is to
remain unchanged.
scale (PLFLT, input)
Scale factor to be applied to default to get actual tick length.
plsori (ori );
Sets the current orientation. If ori is equal to zero (default) then landscape is used (x axis is parallel
to the longest edge of the page), otherwise portrait is used. This option is not supported by all output
drivers (in particular, most interactive screen drivers ignore the orientation). This routine, if used, must
be called before initializing PLplot.
ori (PLINT, input)
Orientation value (0 for landscape, 1 for portrait; the value is multiplied by 90 degrees to get the
angle)
128
Sets the page configuration (optional). Not all parameters are recognized by all drivers and the interpretation is device-dependent. The X-window driver uses the length and offset parameters to determine
the window size and location. This routine, if used, must be called before initializing PLplot.
xp (PLFLT, input)
Number of pixels, x.
yp (PLFLT, input)
Number of pixels, y.
xleng (PLINT , input)
Page length, x.
yleng (PLINT, input)
Page length, y.
xoff (PLINT, input)
Page offset, x.
yoff (PLINT, input)
Page offset, y.
plspause (pause );
plsstrm (strm );
Sets the number of the current output stream. The stream number defaults to 0 unless changed by this
routine. The first use of this routine must be followed by a call initializing PLplot (e.g. plstar).
strm (PLINT, input)
The current stream number.
129
plssub (nx , ny );
This sets up the size of all subsequent symbols drawn by plpoin and plsym. The actual height of a symbol
is the product of the default symbol size and a scaling factor as for the character height.
def (PLFLT, input)
The default height of a symbol in millimeters, should be set to zero if the default height is to remain
unchanged.
scale (PLFLT, input)
Scale factor to be applied to default to get actual symbol height.
plstar: Initialization
plstar (nx , ny );
Initializing the plotting package. The program prompts for the device keyword or number of the desired
output device. Hitting a RETURN in response to the prompt is the same as selecting the first device.
If only one device is enabled when PLplot is installed, plstar will issue no prompt. The output device
is divided into nx by ny sub-pages, each of which may be used independently. The subroutine pladv is
used to advance from one subpage to the next.
nx (PLINT, input)
Number of subpages to divide output page in the horizontal direction.
ny (PLINT, input)
Number of subpages to divide output page in the vertical direction.
130
plstart: Initialization
plstart (device , nx , ny );
Alternative to plstar for initializing the plotting package. The device name keyword for the desired
output device must be supplied as an argument. The device keywords are the same as those printed out
by plstar. If the requested device is not available, or if the input string is empty or begins with ?, the
prompted startup of plstar is used. This routine also divides the output device into nx by ny sub-pages,
each of which may be used independently. The subroutine pladv is used to advance from one subpage to
the next.
device (const char *, input)
Device name (keyword) of the required output device. If NULL or if the first character is a ?, the
normal (prompted) startup is used.
nx (PLINT, input)
Number of subpages to divide output page in the horizontal direction.
ny (PLINT, input)
Number of subpages to divide output page in the vertical direction.
plstripa (id , p , x , y );
Add a point to a given pen of a given stripchart. There is no need for all pens to have the same number
of points or to be equally sampled in the x coordinate. Allocates memory and rescales as necessary.
id (PLINT, input)
Identification number (set up in plstripc) of the stripchart.
p (PLINT, input)
Pen number (ranges from 0 to 3).
x (PLFLT, input)
X coordinate of point to plot.
y (PLFLT, input)
Y coordinate of point to plot.
plstripc (id , xspec , yspec , xmin , xmax , xjump , ymin , ymax , xlpos , ylpos , y_ascl , acc ,
colbox , collab , colline , styline , legline[] , labx , laby , labtop );
131
132
plstripd (id );
This sets up the line style for all lines subsequently drawn. A line consists of segments in which the
pen is alternately down and up. The lengths of these segments are passed in the arrays mark and space
respectively. The number of mark-space pairs is specified by nels . In order to return the line style to
the default continuous line, plstyl should be called with nels =0.(see also pllsty)
nels (PLINT, input)
The number of mark and space elements in a line. Thus a simple broken line can be obtained by
setting nels =1. A continuous line is specified by setting nels =0.
mark (PLINT *, input)
Pointer to array with the lengths of the segments during which the pen is down, measured in
micrometers.
space (PLINT *, input)
Pointer to array with the lengths of the segments during which the pen is up, measured in micrometers.
Plots a three dimensional shaded surface plot within the environment set up by plw3d. The surface is
defined by the two-dimensional array z [nx ][ny ], the point z [i][j] being the value of the function at
(x [i], y [j]). Note that the points in arrays x and y do not need to be equally spaced, but must be
stored in ascending order. For further details see the Section called Three Dimensional Surface Plots in
Chapter 3.
133
opt =BASE_CONT:
A contour plot is drawn at the base XY plane using parameters nlevel and
clevel .
opt =SURF_CONT:
A contour plot is drawn at the surface plane using parameters nlevel and
clevel .
opt =DRAW_SIDES:
draws a curtain between the base XY plane and the borders of the plotted
function.
opt =MAG_COLOR:
the surface is colored according to the value of Z; if MAG_COLOR is not used, then
the default the surface is colored according to the intensity of the reflected light in the surface
from a light source whose position is set using pllightsource.
Set the style for the arrow used by plvect to plot vectors.
arrowx, arrowy (PLFLT *,input)
Pointers to a pair of arrays containing the x and y points which make up the arrow. The arrow is
plotted by joining these points to form a polygon. The scaling assumes that the x and y points in
the arrow lie in the range -0.5 <= x,y <= 0.5.
npts (PLINT,input)
Number of points in the arrays arrowx and arrowy .
134
Alternate routine to plvpor for setting up the viewport. This routine should be used only if the viewport
is required to have a definite size in millimeters. The routine plgspa is useful for finding out the size of
the current subpage.
xmin (PLFLT, input)
The distance of the left-hand edge of the viewport from the left-hand edge of the subpage in
millimeters.
xmax (PLFLT, input)
The distance of the right-hand edge of the viewport from the left-hand edge of the subpage in
millimeters.
ymin (PLFLT, input)
The distance of the bottom edge of the viewport from the bottom edge of the subpage in millimeters.
ymax (PLFLT, input)
The distance of the top edge of the viewport from the bottom edge of the subpage in millimeters.
Sets values of the digmax and digits flags for the x axis. See the Section called Annotating the Viewport
in Chapter 3 for more information.
digmax (PLINT, input)
Variable to set the maximum number of digits for the x axis. If nonzero, the printed label will be
switched to a floating point representation when the number of digits exceeds digmax .
digits (PLINT, input)
Field digits value. Currently, changing its value here has no effect since it is set only by plbox or
plbox3. However, the user may obtain its value after a call to either of these functions by calling
plgxax.
135
plsym (n , x , y , code );
Marks out a set of n points at positions (x [i], y [i]), using the symbol defined by code . The code is
interpreted as an index in the Hershey font tables.
n (PLINT, input)
Number of points to be marked.
x (PLFLT *, input)
Pointer to array with set of x coordinate values for the points.
y (PLFLT *, input)
Pointer to array with set of y coordinate values for the points.
code (PLINT, input)
Code number for the symbol to be plotted.
Identical to plsxax, except that arguments are flags for z axis. See the description of plsxax for more
detail.
digmax (PLINT, input)
Variable to set the maximum number of digits for the z axis. If nonzero, the printed label will be
switched to a floating point representation when the number of digits exceeds digmax .
digits (PLINT, input)
Field digits value. Currently, changing its value here has no effect since it is set only by plbox or
plbox3. However, the user may obtain its value after a call to either of these functions by calling
plgzax.
136
pltext ();
Sets an interactive device to text mode, used in conjunction with plgra to allow graphics and text
to be interspersed. On a device which supports separate text and graphics windows, this command
causes control to be switched to the text window. This can be useful for printing diagnostic messages
or getting user input, which would otherwise interfere with the plots. The program must switch back to
the graphics window before issuing plot commands, as the text (or console) device will probably become
quite confused otherwise. If already in text mode, this command is ignored. It is also ignored on devices
which only support a single window or use a different method for shifting focus (see also plgra).
plvasp (aspect );
Sets the viewport so that the ratio of the length of the y axis to that of the x axis is equal to aspect .
aspect (PLFLT, input)
Ratio of length of y axis to length of x axis.
Draws a vector plot of the vector (u [nx ][ny ],v [nx ][ny ]). The scaling factor for the vectors is given
by scale . A transformation routine pointed to by pltr with a pointer pltr_data for additional data
required by the transformation routine is used to map indices within the array to the world coordinates.
The style of the vector arrow may be set using plsvect.
u, v (PLFLT **, input)
Pointers to a pair of vectored two-dimensional arrays containing the x and y components of the
vector data to be plotted.
nx, ny (PLINT, input)
Physical dimensions of the arrays u and v .
scale (PLFLT, input)
Parameter to control the scaling factor of the vectors for plotting. If scale = 0 then the scaling
factor is automatically calculated for the data. If scale < 0 then the scaling factor is automatically
calculated for the data and then multiplied by -scale . If scale > 0 then the scaling factor is set to
scale .
137
Device-independent routine for setting up the viewport. The viewport is chosen to be the largest with
the given aspect ratio that fits within the specified region (in terms of normalized subpage coordinates).
This routine is functionally equivalent to plvpor when a natural aspect ratio (0.0) is chosen. Unlike
plvasp, this routine reserves no extra space at the edges for labels.
xmin (PLFLT, input)
The normalized subpage coordinate of the left-hand edge of the viewport.
xmax (PLFLT, input)
The normalized subpage coordinate of the right-hand edge of the viewport.
ymin (PLFLT, input)
The normalized subpage coordinate of the bottom edge of the viewport.
ymax (PLFLT, input)
The normalized subpage coordinate of the top edge of the viewport.
aspect (PLFLT, input)
Ratio of length of y axis to length of x axis.
Device-independent routine for setting up the viewport. This defines the viewport in terms of normalized
subpage coordinates which run from 0.0 to 1.0 (left to right and bottom to top) along each edge of the
current subpage. Use the alternate routine plsvpa in order to create a viewport of a definite size.
xmin (PLFLT, input)
The normalized subpage coordinate of the left-hand edge of the viewport.
138
plvsta ();
Sets up a standard viewport, leaving a left-hand margin of seven character heights, and four character
heights around the other three sides.
plw3d (basex , basey , height , xmin , xmax , ymin , ymax , zmin , zmax , alt , az );
Sets up a window for a three-dimensional surface plot within the currently defined two-dimensional
window. The enclosing box for the surface plot defined by xmin , xmax , ymin , ymax , zmin and zmax in
user-coordinate space is mapped into a box of world coordinate size basex by basey by height so that
xmin maps to -basex /2, xmax maps to basex /2, ymin maps to -basey /2, ymax maps to basey /2, zmin
maps to 0 and zmax maps to height . The resulting world-coordinate box is then viewed by an observer
at altitude alt and azimuth az . This routine must be called before plbox3 or plot3d. For a more
complete description of three-dimensional plotting see the Section called Three Dimensional Surface
Plots in Chapter 3.
basex (PLFLT, input)
The x coordinate size of the world-coordinate box.
basey (PLFLT, input)
The y coordinate size of the world-coordinate box.
height (PLFLT, input)
The z coordinate size of the world-coordinate box.
xmin (PLFLT, input)
The minimum user x coordinate value.
xmax (PLFLT, input)
The maximum user x coordinate value.
ymin (PLFLT, input)
The minimum user y coordinate value.
139
plwid (width );
140
Enter (mode !=0) or leave (mode == 0) xor mode for those drivers (e.g., the xwin driver) that support
it. Enables erasing plots by drawing twice the same line, symbol, etc. If driver is not capable of xor
operation returns status of 0.
mode (PLINT, input)
mode != 0 means enter xor mode and mode == 0 means leave xor mode.
status (PLINT *, output)
Pointer to status. Returned status == 1 (0) means driver is capable (incapable) of xor mode.
141
142
initialized
plP_checkdriverinit (list );
Checks to see if any of the specified drivers have been initialized. Function tests a space-delimited list of
driver names to see how many of the given drivers have been initialized, and how often. The return code
of the function is: 0 if no matching drivers were found to have been initialized; -1 if an error occurred
allocating the internal buffer; or, a positive number indicating the number of streams encountered that
belong to drivers on the provided list. This function invokes plP_getinitdriverlist internally to get a
complete list of drivers that have been initialized in order to compare with the driver names specified in
the argument list to plP_checkdriverinit.
list (char *, input)
Pointer to character string specifying a space-delimited list of driver names, e.g., "bmp jpeg tiff".
plP_getinitdriverlist (text_buffer );
Get the initialized-driver list. Function returns a space-delimited list of the currently initialized drivers
or streams. If more than one stream is using the same driver, then its name will be returned more than
once. The function can be analogously thought of as also returning the names of the active streams.
Invoked internally by plP_checkdriverinit.
text_buffer (char *, output)
Pointer to a user-allocated buffer to hold the result. The user must ensure the buffer is big enough
to hold the result.
plabort (message );
143
plexit (message );
This routine is called in case an error is encountered during execution of a PLplot routine. It prints the
error message, tries to release allocated resources, calls the handler prvided by plsexit and then exits.
If cleanup needs to be done in the driver program then the user may want to supply his/her own exit
handler and pass it in via plsexit. This function should either call plend before exiting, or simply return.
message (char *, input)
Error message.
plgfile (file );
plsabort (handler );
plsexit (handler );
144
plsfile (file );
Sets the current output file handle, if applicable. If the file has has not been previously opened and is
required by the driver, the user will be prompted for the file name. This routine, if used, must be called
before initializing PLplot.
file (FILE *, input)
File pointer.
pltr0 (x , y , tx , ty , pltr_data );
Identity transformation for grid to world mapping. This routine can be used both for plcont and plshade.
See also the Section called Contour Plots from C in Chapter 3 and the Section called Shade Plots from
C in Chapter 3.
x (PLFLT, input)
X-position in grid coordinates.
y (PLFLT, input)
Y-position in grid coordinates.
tx (PLFLT *, output)
X-position in world coordinates.
ty (PLFLT *, output)
Y-position in world coordinates.
pltr_data (PLPointer, input)
Pointer to additional input data that is passed as an argument to plcont or plshade and then on to
the grid to world transformation routine.
pltr1: Linear interpolation for grid to world mapping using singly dimensioned
coord arrays
pltr1 (x , y , tx , ty , pltr_data );
145
pltr2: Linear interpolation for grid to world mapping using doubly dimensioned
Linear interpolation for grid to world mapping using doubly dimensioned coord arrays (column dominant,
as per normal C 2d arrays). This routine can be used both for plcont and plshade. See also the Section
called Contour Plots from C in Chapter 3 and the Section called Shade Plots from C in Chapter 3.
x (PLFLT, input)
X-position in grid coordinates.
y (PLFLT, input)
Y-position in grid coordinates.
tx (PLFLT *, output)
X-position in world coordinates.
ty (PLFLT *, output)
Y-position in world coordinates.
pltr_data (PLPointer, input)
Pointer to additional input data that is passed as an argument to plcont or plshade and then on to
the grid to world transformation routine.
146
Draws a contour plot of the data in z [nx ][ny ], using the nlevel contour levels specified by clevel .
Only the region of the array from kx to lx and from ky to ly is plotted out. See the Section called
Contour and Shade Plots in Chapter 3 for more information.
z (PLFLT **, input)
Pointer to a vectored two-dimensional array containing data to be contoured.
nx, ny (PLINT, input)
Physical dimensions of array z .
kx, lx (PLINT, input)
Range of x indices to consider.
ky, ly (PLINT, input)
Range of y indices to consider.
clevel (PLFLT *, input)
Pointer to array specifying levels at which to draw contours.
nlevel (PLINT, input)
Number of contour levels to draw.
NOTE: this function is intended for use from a Fortran caller only. The C user should instead call plcont
using the built-in transformation function pltr0 for the same capability.
147
Draws a contour plot of the data in z [nx ][ny ], using the nlevel contour levels specified by clevel .
Only the region of the array from kx to lx and from ky to ly is plotted out. The arrays xg and yg are
used to specify the transformation between array indices and world coordinates. See the Section called
Contour and Shade Plots in Chapter 3 for more information.
z (PLFLT **, input)
Pointer to a vectored two-dimensional array containing data to be contoured.
nx, ny (PLINT, input)
Physical dimensions of array z .
kx, lx (PLINT, input)
Range of x indices to consider.
ky, ly (PLINT, input)
Range of y indices to consider.
148
When called from Fortran, this routine has the same effect as when invoked from C. The interpretation
of all parameters (see plcont) is also the same except there is no transformation function supplied as the
last parameter. Instead, a 6-element array specifying coefficients to use in the transformation is supplied
via the named common block plplot (see code). Since this approach is somewhat inflexible, the user is
recommended to call either of plcon0, plcon1, or plcon2 instead.
plvec0 (u , v , nx , ny , scale );
Draws a vector plot of the data in (u [nx ][ny ], v [nx ][ny ]).
u, v (PLFLT **, input)
Pointer to a pair of vectored two-dimensional arrays containing the x and y components of the
vector to be plotted.
nx, ny (PLINT, input)
Physical dimensions of the arrays u and v .
scale (PLFLT, input)
Parameter to control the scaling factor of the vectors for plotting. If scale = 0 then the scaling
factor is automatically calculated for the data. If scale < 0 then the scaling factor is automatically
calculated for the data and then multiplied by -scale . If scale > 0 then the scaling factor is set to
scale .
NOTE: this function is intended for use from a Fortran caller only. The C user should instead call plvect
using the built-in transformation function pltr0 for the same capability.
149
plvec1 (u , v , nx , ny , scale , xg , yg );
Draws a vector plot of the data in (u [nx ][ny ], v [nx ][ny ]).
u, v (PLFLT **, input)
Pointer to a pair of vectored two-dimensional arrays containing the x and y components of the
vector to be plotted.
nx, ny (PLINT, input)
Physical dimensions of the arrays u and v .
scale (PLFLT, input)
Parameter to control the scaling factor of the vectors for plotting. If scale = 0 then the scaling
factor is automatically calculated for the data. If scale < 0 then the scaling factor is automatically
calculated for the data and then multiplied by -scale . If scale > 0 then the scaling factor is set to
scale .
xg, yg (PLFLT *, input)
Pointers to arrays which specify the transformation from array indices to world coordinates. These
must be one-dimensional arrays, used for a transformation of the form: tx = f(x), ty = f(y).
Function values at locations between grid points are obtained via linear interpolation.
NOTE: this function is intended for use from a Fortran caller only. The C user should instead call plvect
using the built-in transformation function pltr1 for the same capability.
plvec2 (u , v , nx , ny , scale , xg , yg );
Draws a vector plot of the data in (u [nx ][ny ], v [nx ][ny ]).
u, v (PLFLT **, input)
Pointer to a pair of vectored two-dimensional arrays containing the x and y components of the
vector to be plotted.
nx, ny (PLINT, input)
Physical dimensions of the arrays u and v .
scale (PLFLT, input)
Parameter to control the scaling factor of the vectors for plotting. If scale = 0 then the scaling
factor is automatically calculated for the data. If scale < 0 then the scaling factor is automatically
calculated for the data and then multiplied by -scale . If scale > 0 then the scaling factor is set to
scale .
150
plvect (u , v , nx , ny , scale );
When called from Fortran, this routine has the same effect as when invoked from C. The interpretation
of all parameters (see plvect) is also the same except there is no transformation function supplied as the
last parameter. Instead, a 6-element array specifying coefficients to use in the transformation is supplied
via the named common block plplot (see code). Since this approach is somewhat inflexible, the user is
recommended to call either of plvec0, plvec1, or plvec2 instead.
plmesh (x , y , z , nx , ny , opt , mx );
When called from Fortran, this routine has the same effect as when invoked from C. The interpretation
of all parameters (see plmesh) is also the same except there is an additional parameter given by:
mx (PLINT, input)
Length of array in x direction, for plotting subarrays.
When called from Fortran, this routine has the same effect as when invoked from C. The interpretation
of all parameters (see plot3d) is also the same except there is an additional parameter given by:
mx (PLINT, input)
Length of array in x direction, for plotting subarrays.
plsesc: Set the escape character for text strings for fortran
plsesc (esc );
151
!, ASCII 33
#, ASCII 35
$, ASCII 36
%, ASCII 37
&, ASCII 38
*, ASCII 42
@, ASCII 64
^, ASCII 94
~, ASCII 126
152
plgcompression
plgdev
plgdidev
plgdiori
plgdiplt
plgesc
plgfam
plgfile
plgfnam
plglevel
plgpage
plgra
plgriddata
plgspa
plgstrm
plgver
plgvpd
plgvpw
plgxax
plgyax
plgzax
plhist
plhls
plimage
plinit
pljoin
pllab
pllightsource
plline
plline3
pllsty
plmap
plmeridians
plmesh
plmeshc
plmkstrm
plmtex
plscmap1n
plscol0
plscolbg
plscolor
plscompression
plsdev
plsdidev
plsdimap
plsdiori
plsdiplt
plsdiplz
plseopH
plsesc
plsetopt
plsexit
plsfam
plsfile
plsfnam
plshade
plshade1
plshades
plsmaj
plsmem
plsmin
plsori
plspage
plspause
plsstrm
plssub
plssym
plstar
plstart
plstr
plstripa
plstripc
plstripd
plstyl
153
plot3d
plot3dc
plot3dcl
plpat
plpoin
plpoin3
plpoly3
plprec
plpsty
plptex
plreplot
plrgb
plrgb1
plsButtonEH
plsError
plsKeyEH
plsabort
plsbopH
plschr
plscmap0
plscmap0n
plscmap1
plscmap1l
plsurf3d
plsurf3dl
plsvect
plsvpa
plsxax
plsxwin
plsyax
plsym
plszax
pltext
pltr0
pltr1
pltr2
pltr2p
plvasp
plvect
plvpas
plvpor
plvsta
plw3d
plwid
plwind
plxormod
Another important aspect of compatibility regard the Application Binary Interface (ABI). Backwards
compatibility can be broken by changes in the C structures made public through plplot.h. Currently,
they are:
typedef struct {
char *opt;
int (*handler) (char *, char *, void *);
void *client_data;
void *var;
long mode;
char *syntax;
char *desc;
} PLOptionTable;
typedef struct {
int type;
/* of event (CURRENTLY UNUSED) */
unsigned int state; /* key or button mask */
unsigned int keysym; /* key selected */
unsigned int button; /* mouse button selected */
PLINT subwindow;
/* subwindow (alias subpage, alias subplot) number */
char string[PL_MAXKEY]; /* translated string */
int pX, pY;
/* absolute device coordinates of pointer */
PLFLT dX, dY; /* relative device coordinates of pointer */
PLFLT wX, wY; /* world coordinates of pointer */
} PLGraphicsIn;
typedef struct {
PLFLT dxmi, dxma, dymi, dyma; /* min, max window rel dev coords */
PLFLT wxmi, wxma, wymi, wyma; /* min, max window world coords */
} PLWindow;
typedef struct {
154
{
/*
/*
/*
/*
/*
/* red */
/* green */
/* blue */
hue */
lightness */
saturation */
position */
if set, interpolate through h=0 */
typedef struct {
PLINT cmd;
PLINT result;
} PLBufferingCB;
155
Check if there are any changes in plplot.h. If no prototype is changed, then the chances are high that
no backwards compatibilities have been introduced. If new functions has been added, then the library
soname will be kept, although the libtool soversion string in configure.ac must be changed from x:y:z
to (x+1):0:(z+1). See the libtool manual for details.
A necessary, but not sufficient test consists of the following: first, install the previous released version
of PLplot in the system and compile all the examples examples/c/x??c.. After that, install the to-bereleased version of PLplot and try to run the previously compiled examples. If they either link or run
incorrectly, then backwards incompatibilities have been introduced and the soversion string must be
upgraded from x:y:z to (x+1):0:0.
156
Linux/Unix Notes
Linux/Unix Configure, Build, and Installation
Here is the short story:
./configure
make
make install
The longer story is there are a lot of possible configure options. Two of the more important configure
options are --prefix and --with-double. Here is the complete list of configuration options:
./configure --help
No defaults file found, performing full configure.
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE
cache test results in FILE
--help
print this message
--no-create
do not create output files
--quiet, --silent
do not print checking... messages
--version
print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX
install architecture-independent files in PREFIX
[/usr/local/plplot]
--exec-prefix=EPREFIX
install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR
user executables in DIR [EPREFIX/bin]
--sbindir=DIR
system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR
program executables in DIR [EPREFIX/libexec]
--datadir=DIR
read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR
read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR
modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR
modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR
object code libraries in DIR [EPREFIX/lib]
--includedir=DIR
C header files in DIR [PREFIX/include]
--oldincludedir=DIR
C header files for non-gcc in DIR [/usr/include]
--infodir=DIR
info documentation in DIR [PREFIX/info]
--mandir=DIR
man documentation in DIR [PREFIX/man]
--srcdir=DIR
find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
157
158
The configure script looks for default configuration options first in ./cf_plplot.in. If that file is not
found, the script then looks in $HOME/config/cf_plplot.in. Finally, if neither file is found or if the found
file does not have a particular default option, then the script uses the above defaults. Here is one example
of a default configuration file. Adapt this for your needs or else use the command-line parameters for
the configuration file.
#
#
#
#
#
#
#
#
#
#
159
160