[R] filled.contour and NA's

hadley wickham h.wickham at gmail.com
Mon Dec 11 15:37:46 CET 2006


> I'm trying to do a filled.contour plot where some points are labelled as
> NA. How do I could plot this kind of graphics, so NA points are coloured
> black,  keeping the levels of remaining points. NA's values represent
> land points (meaningless), and what I want to plot is the levels of a
> variable over the sea.

You can also do this using ggplot, although you don't have quite as
much control over the appearance of the contours (you do get more
control over other things)

install.packages("ggplot", dep=T)
library(ggplot)

# Set up appropriate data structure
dimnames(ene) <- list(y, x)
names(dimnames(ene)) <- c("y", "x")
enem <- melt(ene)

p <- ggplot(na.omit(enem), aes=list(x=x, y=y, z=value, fill=value))
p <- ggtile(p)
p <- ggcontour(p)
scfillgradient(p)
scfillgradient(p, low="white", high="blue")

Regards,

Hadley




More information about the R-help mailing list