contourPlot {contourPlot} | R Documentation |
Plot a contour map
Description
Takes x,y,z co-ordinates and plots them on a contour map. Smoothing and interpolation is done by means of fitting a spline to the data.
Usage
contourPlot(
x,
y,
z,
nx = length(unique(x)),
main = NULL,
axis = TRUE,
legend = TRUE,
xlab = "",
ylab = "",
col = NULL,
breaks = NULL,
nlevels = 10,
legend_pos = 4
)
Arguments
x |
a vector of x co-ordinates |
y |
a vector of y co-ordinates |
z |
a vector of z co-ordinates representing the height of the contours |
nx |
The number of pixels that will be in final plot. default is length(unique(x)) |
main |
Title of plot |
axis |
logical if TRUE displays the axes of the plot |
legend |
logical if TRUE displays the legend |
xlab |
label on x axis |
ylab |
label on y axis |
col |
list of colors to be applied to contours. |
breaks |
list of values indicating the contour ranges |
nlevels |
useful if breaks and col are left as null. Sets the number of levels of the contours to be plotted |
legend_pos |
set position of the colour bar. Default = 4. |
Value
A contour plot (similar to those in base, additional elements can be added using lines, points functions etc.
Examples
x <- Volcontour$x
y <- Volcontour$y
z <- Volcontour$z
contourPlot(x = x, y = y, z = z)
# A smoother contour
contourPlot(x = x, y = y, z = z, nx = 500)
# Changing breaks and colours
breaks = pretty(c(min(z),max(z)))
col = brewer.pal(n = length(breaks)-1, "Blues")
contourPlot(x = x, y = y, z = z, nx = 500, breaks = breaks, col = col)
# add lines
lines(circle(0, 0, 26.5))