Seguimi in Twitter Seguimi in Facebook Seguimi in Pinterest Seguimi in LinkedIn Seguimi in Google+ Seguimi  in Stumbleupon seguimi  in instagram Sottoscrivi il feed
Blender, graphic, software, open source, Linux LibreOffice, open source, openoffice Gimp, graphic, software, open source, Linux kernel, Linux, software, open source Linux, distributions, Ubuntu, Linux Mint, Fedora, Mandriva Jamin, gpl, library, open source matroska, multimedia, container, linux pcman, file manager, linux LuninuX, distribition, Linux, open source Linux, infographic, history
Home » , , , » The PLplot Library User Guide: Simple Use of PLplot.

The PLplot Library User Guide: Simple Use of PLplot.

PLplot is a library of C functions that are useful for making scientific plots from programs written in C, C++, Fortran95, Java, Octave, Perl, 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 is full unicode support in the PLplot library, and most of the display drivers are capable of displaying any of the millions(?) of characters in the unicode standard.


Plotting a Simple Graph.

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

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

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

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

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

    plinit, to initialize PLplot.

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

    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.

    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.

Defining Plot Scales and Axes

The function plenv is used to define the scales and axes for simple graphs. plenv starts a new picture on the next subpage (or a new page if necessary), and defines the ranges of the variables required. The routine will also draw a box, axes, and numeric labels if requested. The syntax for plenv is:

plenv (    xmin,

xmin, xmax (PLFLT, input)

    The left and right limits for the horizontal axis.
ymin, ymax (PLFLT, input)

    The bottom and top limits for the vertical axis.
just (PLINT, input)

    This should be zero or one. If just is one, the scales of the x-axis and y-axis will be the same (in units per millimeter); otherwise the axes are scaled independently. This parameter is useful for ensuring that objects such as circles have the correct aspect ratio in the final plot.
axis (PLINT, input)

    axis controls whether a box, tick marks, labels, axes, and/or a grid are drawn.

        axis = -2: No box or annotation.

        axis = -1: Draw box only.

        axis = 0: Draw box, labelled with coordinate values around edge.

        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.

        axis = 10: Logarithmic X axis, linear Y axis.

        axis = 11: Logarithmic X axis, linear Y axis and draw line Y = 0.

        axis = 20: Linear X axis, logarithmic Y axis.

        axis = 21: Linear X axis, logarithmic Y axis and draw line X = 0.

        axis = 30: Logarithmic X and Y axes.

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 labelling and tick intervals, more complex graphs should make use of the functions plvpor, plvasp, plvpas, plwind, plbox, and routines for manipulating axis labelling plgxax through plszax.


Labelling the Graph.

The function pllab may be called after plenv to write labels on the x and y axes, and at the top of the picture. All the variables are character variables or constants. Trailing spaces are removed and the label is centered in the appropriate field. The syntax for pllab is:

pllab (    xlbl,

xlbl (char *, input)

    Pointer to string with label for the X-axis (bottom of graph).
ylbl (char *, input)

    Pointer to string with label for the Y-axis (left of graph).
toplbl (char *, input)

    Pointer to string with label for the plot (top of picture).}

Drawing the Graph.

PLplot can draw graphs consisting of points with optional error bars, line segments or histograms. Functions which perform each of these actions may be called after setting up the plotting environment using plenv. All of the following functions draw within the box defined by plenv, and any lines crossing the boundary are clipped. Functions are also provided for drawing surface and contour representations of multi-dimensional functions. See Chapter 3, Advanced Use of PLplot for discussion of finer control of plot generation.
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 0–31 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,

plsym (    n,

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

Drawing Lines or Curves.

PLplot provides two functions for drawing line graphs. All lines are drawn in the currently selected color, style and width. See the section called “Setting Line Attributes” for information about changing these parameters.

plline draws a line or curve. The curve consists of n-1 line segments joining the n points in the input arrays. For single line segments, pljoin is used to join two points.

plline (    n,

n (PLINT, input)

    The number of points.
x, y (PLFLT *, input)

    Pointers to arrays with coordinates of the n points.

pljoin (    x1,

x1, y1 (PLFLT, input)

    Coordinates of the first point.
x2, y2 (PLFLT, input)

    Coordinates of the second point.


Writing Text on a Graph.

plptex allows text to be written within the limits set by plenv. The reference point of a text string may be located anywhere along an imaginary horizontal line passing through the string at half the height of a capital letter. The parameter just specifies where along this line the reference point is located. The string is then rotated about the reference point through an angle specified by the parameters dx and dy, so that the string becomes parallel to a line joining (x, y) to (x+dx, y+dy).

plptex (    x,

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.

plfill (    n,

n (PLINT, input)

    The number of vertices.
x, y (PLFLT *, input)

    Pointers to arrays with coordinates of the n vertices.


If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:

0 commenti:

Post a Comment

Random Posts

My Blog List

Recent Posts

Recent Posts Widget

Popular Posts




Images Photo Gallery

page counter Mi Ping en TotalPing.com
Copyright © 2014 Linuxlandit & The Conqueror Penguin