[R] Ploting NA location points
xyzzy at speakeasy.org
Fri Aug 11 12:45:34 CEST 2000
> Kenneth Cabrera <krcabrer at epm.net.co> writes:
> > How can I plot a x,y coordinates, but to plot a "z" variable
> > with a different color if it is a z missing value (NA)?
plot(x,y, pch=21, bg=c(4,2)[is.na(z)+1])
You need to use a point type from 21 to 25 for the background color to show
up. If you don't want a filled point, use col instead of bg and whatever
point type you want. You could also do something like
"pch=c(20,1)[is.na(z)+1]", to get different point types when z is missing.
To go along with the plot, I suggest something like:
legend(0,0, c("Non-Missing", "Missing"), fill=c(4,2))
The legend will have square boxes of color instead of filled circles like
pch=21,bg=c(...) will give you. I haven't been able to figure out how to get
a color filled symbol in a plot legend. The bg parameter will apply to the
background of the entire legend, and not the plotting symbols.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help