Learn R Programming

plotfunctions (version 1.4)

color_contour: Creates a contour plot with colored background.

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

color_contour(
  x = seq(0, 1, length.out = nrow(z)),
  y = seq(0, 1, length.out = ncol(z)),
  z,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  xlim = NULL,
  ylim = NULL,
  zlim = NULL,
  col = NULL,
  color = topo.colors(50),
  nCol = 50,
  add.color.legend = TRUE,
  ...
)

Arguments

x

Locations of grid lines at which the values in z are measured. These must be in ascending order. By default, equally spaced values from 0 to 1 are used. If x is a list, its components x$x and x$y are used for x and y, respectively. If the list has component z this is used for z.

y

Locations of grid lines at which the values in z are measured.

z

a matrix containing the values to be plotted (NAs are allowed). Note that x can be used instead of z for convenience.

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.

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.

...

Optional parameters for image and contour.

See Also

image, contour, filled.contour. See plotsurface for plotting model predictions using color_contour.

plotsurface

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

Examples

Run this code
# NOT RUN {
# Volcano example of R (package datasets)
color_contour(z=volcano)
# change color and lines:
color_contour(z=volcano, color='terrain', col=alpha(1), lwd=2, lty=5)
# change x-axis values and zlim:
color_contour(x=seq(500,700, length=nrow(volcano)),
    z=volcano, color='terrain', col=alpha(1), lwd=2, zlim=c(0,200))

# compare with similar functions:
filled.contour(volcano, color.palette=terrain.colors)

# without contour lines:
color_contour(z=volcano, color='terrain', lwd=0, drawlabels=FALSE)
# without background:
color_contour(z=volcano, color=NULL, add.color.legend=FALSE)
# }

Run the code above in your browser using DataLab