The current version of Dan Kelley’s oce package now has a branch testing some new functions for creating “colormaps” — the design here being that there is a way to map levels (say topographic height, or velocity, etc) to a specific set of colors. Development work on this has been ongoing in the
colorize branch of the oce repo on Github. See Dan’s blog post at: http://dankelley.github.io/r/2014/04/30/colormap.html for more information.
Many of the standard plotting commands that
oce uses already mostly take advantage of the idea of a colormap (such as
drawPalette()), but recent use cases showed that there was much room for improvements. In particular, the connection between choosing a color scheme for a range of values, was previously up to the user to make sure they matched. This was most commonly done with the
rescale() function, but it was found that it is not an ideal solution when the number of color levels is small.
Create a colormap for use in an
imagep() plot of the
library(oce) # I have built this from the `colorize` branch commit 365d7700f5be33e5 data(adp) t <- adp[["time"]] z <- adp[["distance"]] p <- adp[["pressure"]] u <- adp[["v"]][, , 1] par(mar = c(3, 3, 1, 1)) pcol <- Colormap(p) plot(t, p, bg = pcol$zcol, pch = 21)
<br />## now for an imagep ucol <- Colormap(u, col = oceColors9B) imagep(t, z, u, colormap = ucol, filledContour = TRUE)