Creates a colored surface plot from data frame input.

Share:

Description

This function is a wrapper around image and contour. See vignette("plotfunctions") for an example of how you could use image and contour.

Usage

1
2
3
4
plotsurface(data, view, predictor = NULL, valCI = NULL, main = NULL,
  xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, zlim = NULL,
  col = NULL, color = topo.colors(50), ci.col = c("red", "green"),
  nCol = 50, add.color.legend = TRUE, dec = NULL, ...)

Arguments

data

Data frame or list with plot data. A data frame needs to have a column with x values, a column with y values and a column with z values. A list contains a vector with unique x values, a vector with unique y values, and a matrix with z-values. The output of the function fvisgam is an example of a suitable list.

view

A vector with the names or numbers of the columns to plot on the x axis and y axis respectively.

predictor

Optional: the name of the column in the data frame data that provides the z-values. If data contains more than one column besides the x- and y-values, the predictor should be provided.

valCI

Optional: the name of the column in the data frame data that provides the CI-values. If not NULL, CI contour lines will be plotted.

main

Text string, an overall title for the plot.

xlab

Label for x axis. Default is name of first view variable.

ylab

Label for y axis. Default is name of second view variable.

xlim

x-limits for the plot.

ylim

y-limits for the plot.

zlim

z-limits for the plot.

col

Color for the contour lines and labels.

color

a list of colors such as that generated by rainbow, heat.colors colors, topo.colors, terrain.colors or similar functions.

ci.col

Two-value vector with colors for the lower CI contour lines and for the upper CI contour lines.

nCol

The number of colors to use in color schemes.

add.color.legend

Logical: whether or not to add a color legend. Default is TRUE. If FALSE (omitted), one could use the function gradientLegend to add a legend manually at any position.

dec

Numeric: number of decimals for rounding the color legend. When NULL (default), no rounding. If -1 (default), automatically determined. Note: if value = -1 (default), rounding will be applied also when zlim is provided.

...

Optional parameters for image and contour.

Author(s)

Jacolien van Rij

See Also

image, contour, color_contour

Other Functions for plotting: addInterval, add_bars, add_n_points, alphaPalette, alpha, check_normaldist, color_contour, dotplot_error, drawArrows, emptyPlot, errorBars, fill_area, getCoords, getFigCoords, getProps, gradientLegend, legend_margin, marginDensityPlot, plot_error, plot_image

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# From the package graphics, see help(image):
x <- 10*(1:nrow(volcano))
y <- 10*(1:ncol(volcano))
image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
contour(x, y, volcano, levels = seq(90, 200, by = 5),
        add = TRUE, col = "peru")
axis(1, at = seq(100, 800, by = 100))
axis(2, at = seq(100, 600, by = 100))
box()
title(main = "Maunga Whau Volcano", font.main = 4)

# now with plot surface:
# first convert to data frame
tmp <- data.frame(value = as.vector(volcano), 
    x = 10*rep(1:nrow(volcano), ncol(volcano)), 
    y = 10*rep(1:ncol(volcano), each=nrow(volcano)))
plotsurface(tmp, view=c('x', "y"), predictor='value', main="Maunga Whau Volcano")

# or with terrain colors:
plotsurface(tmp, view=c('x', "y"), predictor='value', 
    main="Maunga Whau Volcano", color="terrain")

# change color range:
plotsurface(tmp, view=c('x', "y"), predictor='value', 
    main="Maunga Whau Volcano", zlim=c(0,200))

#' remove color and color legend:
plotsurface(tmp, view=c('x', "y"), predictor='value', 
    main="Maunga Whau Volcano", 
    color=NULL, col=1, add.color.legend=FALSE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.