Learn R Programming

plotfunctions (version 1.4)

emptyPlot: Utility function

Description

Generate an empty plot window.

Usage

emptyPlot(
  xlim,
  ylim,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  h0 = NULL,
  v0 = NULL,
  bty = "n",
  eegAxis = FALSE,
  xmark = NULL,
  ymark = NULL,
  ...
)

Arguments

xlim

A one- or two-value vector indicating the range of the x-axis. If xlim is a number, then it is assumed that the other value is 0. Thus, xlim=3000 wil result in a x-axis ranging from 0 to 3000, and xlim=-3 will result in a x-axis ranging from -3 to 0. Optional, xlim can be a vector with categorical x-axis labels.

ylim

A one- or two-value vector indicating the range of the y-axis. (See xlim) for more information. Optional, ylim can be a vector with categorical y-axis labels.

main

Title for the plot. Empty by default. Note: the title can be added later using title.

xlab

Label for x-axis. Empty by default. If no label is provided, use mtext for adding axis labels.

ylab

Label for y-axis. Empty by default. (See xlab.)

h0

A vector indicating where to add solid horizontal lines for reference. By default no values provided.

v0

A vector indicating where to add dotted vertical lines for reference. By default no values provided.

bty

A character string which determined the type of box which is drawn about plots. If bty is one of 'o', 'l', '7', 'c', 'u', or ']' the resulting box resembles the corresponding upper case letter. A value of 'n' (the default) suppresses the box.

eegAxis

Logical: whether or not to reverse the y-axis, plotting the negative amplitudes upwards as traditionally is done in EEG research. If eeg.axes is TRUE, labels for x- and y-axis are provided, when not provided by the user. Default value is FALSE.

xmark

Numeric factor with x-axis tick marks and limits. If NULL (default) R's default system is used. If TRUE, only the xlim values are indicated.

ymark

Numeric factor with y-axis tick marks and limits. If NULL (default) R's default system is used. If TRUE, only the ylim values are indicated.

...

Other arguments for plotting, see par.

Value

An empty plot window.

See Also

Use title and mtext for drawing labels and titles; use lines and points for plotting the data; use legend or legend_margin for adding a legend.

Other Functions for plotting: addInterval(), add_bars(), add_n_points(), alphaPalette(), alpha(), check_normaldist(), color_contour(), dotplot_error(), drawDevArrows(), errorBars(), fill_area(), getCoords(), getFigCoords(), getProps(), gradientLegend(), legend_margin(), marginDensityPlot(), plot_error(), plot_image(), plotsurface(), sortBoxplot()

Examples

Run this code
# NOT RUN {
# generate some measurements:
x <- runif(100,0,100)
y <- rpois(100,lambda=3)

# Setup empty plot window fitting for data:
emptyPlot(range(x), range(y))
# To add data, use lines() and points()
points(x,y, pch=16, col=alpha('steelblue'))

# Category labels:
emptyPlot(toupper(letters[1:5]), 1)
# order matters:
emptyPlot(sample(toupper(letters[1:5])), 1)
# actually, they are plotted on x-positions 1:5
points(1:5, rnorm(5, mean=.5, sd=.1))
# also possible for y-axis or both:
emptyPlot(c(200,700), toupper(letters[1:5]))
emptyPlot(as.character(8:3), toupper(letters[1:5]))
# change orientation of labels:
par(las=1)
emptyPlot(c(200,700), toupper(letters[1:5]))
par(las=0) # set back to default

# More options:
emptyPlot(range(x), range(y),
    main='Data', ylab='Y', xlab='Time')
# add averages:
m <- tapply(y, list(round(x/10)*10), mean)
lines(as.numeric(names(m)), m, type='o', pch=4)

# with vertical and horizontal lines:
emptyPlot(1, 1, h0=.5, v0=.75)
# eeg axis (note the axes labels):
emptyPlot(c(-200,1000), c(-5,5),
    main='EEG', v0=0, h0=0,
    eegAxis=TRUE)

# simplify axes:
emptyPlot(c(-3.2,1.1), c(53,58),
    xmark=TRUE, ymark=TRUE, las=1)
# compare with R default:
emptyPlot(c(-3.2,1.1), c(53,58), las=1)
# also possible to specify values manually:
emptyPlot(c(-3.2,1.1), c(53,58),
    xmark=c(-3.2,0, 1.1), ymark=c(55,57), las=1)

# empty window:
emptyPlot(1,1,axes=FALSE)
# add box:
emptyPlot(1,1, bty='o')

# }

Run the code above in your browser using DataLab