Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gp.open

Alpha version functions to send plotting commands to GnuPlot


Description

These functions allow you to open a connection to a gnuplot process, send data and possibly other information to gnuplot for it to plot, then close gnuplot and clean up temporary files and variables. These functions are alpha level at best, use at your own risk.

Usage

gp.open(where='c:/progra~1/GnuPlot/bin/pgnuplot.exe')
gp.close(pipe=gpenv$gp)
gp.send(cmd='replot',pipe=gpenv$gp)
gp.plot(x,y,type='p',add=FALSE, title=deparse(substitute(y)),pipe=gpenv$gp)
gp.splot(x,y,z, add=FALSE, title=deparse(substitute(z)), pipe=gpenv$gp,
  datafile=tempfile())

Arguments

where

Path to GnuPlot Executable

pipe

The pipe object connected to GnuPlot (returned from gp.open), warning: changing this from the default will probably break things

cmd

Text string, the command to be sent verbatim to the GnuPlot process

x

The x coordinates to plot

y

the y coordinates to plot

z

the z coordinates to splot

type

Either 'p' or 'l' for plotting points or lines

add

Logical, should the data be added to the existing plot or start a new plot

title

The title or legend entry

datafile

The file to store the data in for transfer to gnuplot

Details

These functions provide a basic interface to the GnuPlot program (you must have GnuPlot installed (separate install)), gp.open runs GnuPlot and establishes a pipe connection, gp.close sends a quite command to gnuplot and cleans up temporary variables and files, gp.send sends a command to the GnuPlot process verbatim, and gp.plot sends data and commands to the process to create a standard scatterplot or line plot.

Value

gp.open returns and invisible copy of the pipe connection object (to pass to other functions, but don't do this because it doesn't work right yet).

The other 3 functions don't return anything meaningful. All functions are run for their side effects.

Note

These functions create some temporary files and 2 temporary global variables (.gp and .gp.tempfiles), running gp.close will clean these up (so use it).

These functions are still alpha level.

Author(s)

Greg Snow 538280@gmail.com

References

See Also

Examples

## Not run: 

x <- 1:10
y <- 3-2*x+x*x+rnorm(10)

gp.open()
gp.plot(x,y)
gp.send('replot 3-2*x+x**2')

tmp <- expand.grid(x=1:10, y=1:10)
tmp <- transform(tmp, z=(x-5)*(y-3))
gp.splot(tmp$x, tmp$y, tmp$z)

gp.close()
 
## End(Not run)

TeachingDemos

Demonstrations for Teaching and Learning

v2.12
Artistic-2.0
Authors
Greg Snow
Initial release
2020-04-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.