For threshold:
plot(v[v$copper>31,], pch = 2, col="blue")
points(v[v$copper<=31,], pch = 6, col="red")
For proportional:
plot(v, cex=(3*(v$copper)/max(v$copper)), pch=16)
Apologies; ggplot for shape:
v@data$threshold = ifelse(v$copper > 31, "a", "b")
ggplot(data=v@data,
aes(x=x,y=y, shape = threshold)) +
geom_point() +
scale_shape_manual(values=c(2,6))
ggplot code for proportional:
ggplot(data=v@data,
aes(x=x,y=y, size = copper)) +
geom_point()
Upon reflection, I think you'd be better off making a call to the coordinates slot rather than x
and y
from v
. This is because x
and y
are fixed in the dataframe part of the SpatialPointsDataFrame. Instead, doing something like what I have below plots based on the spatial part of things and is robust to transformations on the object.
# Assume a sample spatial argument for the dataframe
proj4string(v) = CRS("+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs")
proj4string(v)
# spatial transformation
v2 = spTransform(v,
CRSobj = CRS("+init=epsg:4326"))
proj4string(v2)
# Plotting this way enables plotting based on transformations
ggplot(data=v2@data,
aes(x=coordinates(v2)[,1],y=coordinates(v2)[,2],
shape = threshold)) +
geom_point() +
scale_shape_manual(values=c(2,6))