# colPoints: Points colored relative to third dimension In berryFunctions: Function Collection Related to Plotting and Hydrology

## Description

Draw colored points for 3D-data in a 2D-plane. Color is relative to third dimension, by different classification methods. Can take 3 vectors or, as in image, 2 vectors and a matrix for z.
Adding points after smallPlot is called for the legend may be incorrect if the original function messes with the graph margins, see the note in colPointsLegend.

## Usage

 1 2 3 4 5 6 7 8 9 colPoints(x, y, z, data, add = TRUE, col = seqPal(100), col2 = c(NA, "grey", "black"), Range = range(z, finite = TRUE), method = "linear", breaks = length(col), sdlab = 1, legend = TRUE, legargs = NULL, lines = FALSE, nint = 30, xlab = gsub("\"", "", deparse(substitute(x))), ylab = gsub("\"", "", deparse(substitute(y))), zlab = gsub("\"", "", deparse(substitute(z))), axes = TRUE, log = "", las = 1, bglines = NULL, pch = 16, x1 = 0.6, y1 = ifelse(horizontal, 0.88, 0.3), x2 = 0.99, y2 = 0.99, density = NULL, horizontal = TRUE, quiet = FALSE, ...)

## Arguments

 x, y Vectors with coordinates of the points to be drawn z z values belonging to coordinates. Vector or matrix with the color-defining height values data Optional: data.frame with the column names as given by x,y and z. add Logical. Should the points be added to current (existing!) plot? If FALSE, a new plot is started. DEFAULT: TRUE (It's called colPoints, after all) col Vector of colors to be used. DEFAULT: 100 colors from sequential palette seqPal (color-blind safe, black/white-print safe) col2 Color for points where z is NA, or lower / higher than Range. DEFAULT: c(NA, 1, 8) Range Ends of color bar. If NULL, it is again the DEFAULT: range(z, finite=TRUE) method Classification method (partial matching is performed), see classify. DEFAULT: "linear" breaks Specification for method, see classify. DEFAULT: different defaults for each method sdlab Type of label and breakpoints if method="sd", see classify. DEFAULT: 1 legend Logical. Should a colPointsLegend be drawn? DEFAULT: TRUE legargs List. Arguments passed to colPointsLegend. DEFAULT: NULL, with some defaults specified internally lines Logical. Should lines be drawn instead of / underneath the points? (color of each segments is taken from starting point, last point is endpoint.) If lines=TRUE and pch is not given, pch is set to NA. DEFAULT: FALSE nint Numeric of length 1. Number of interpolation points between each coordinate if lines=TRUE. nint=1 means no interpolation. Values below 10 will smooth coordinates and might miss the original points. DEFAULT: 30 xlab, ylab, zlab X axis label, y axis label, colPointsLegend title. DEFAULT: gsub("\"", "", deparse(substitute(x/y/z))) axes, las Draw axes? Label Axis Style. Only used when add=FALSE. See par. DEFAULT: axes=TRUE, las=1 (all labels horizontal) log Logarithmic axes with log="y", "xy" or "x". DEFAULT: "" bglines If not NULL, passed to abline to draw background lines before adding colored points. DEFAULT: NULL pch Point CHaracter. See par. DEFAULT: 16 x1, x2, y1, y2 Relative coordinates [0:1] of inset plot, see smallPlot. Passed to colPointsLegend. DEFAULT: x: 0.6-0.99, y: 0.88-0.98 density Arguments for density line in colPointsLegend, or FALSE to suppress drawing it. DEFAULT: NULL horizontal Logical passed to colPointsLegend. DEFAULT: TRUE quiet Turn off warnings? DEFAULT: FALSE ... Further graphical arguments passed to plot, points and segments, eg cex, xlim (when add=F), mgp, main, sub, asp (when add=F), etc. Note: col does not work, as it is already another argument

## Value

Invisible list of values that can be passed to colPointsLegend or colPointsHist.

## Note

Rstudio scales graphics really badly, so don't expect the right legend width out of the box if you use Rstudio! Exporting via png("myplot.png", 600,400); colPoints(x,y,z); dev.off() usually works much better

## Author(s)

Berry Boessenkool, [email protected], 2011-2014. I'd be interested in hearing what you used the function for.