I seek help on how to change font size and font color for sp.text
labels on the attached map—to avoid overlapping of labels and to improve readability.
Map was produced as below. If needed, one may download the SpatialPolygonsDataframe
object 'mymap' here.
trellis.par.set()
is not solving my problem. Am I using it incorrectly?
library(sp)
library(latticeExtra)
# Create list object for sp.layout (Got these functions here on stackoverflow, thank you owner)
sp.label <- function(x, label) {list("sp.text", coordinates(x), label)}
NUMB.sp.label <- function(x) {sp.label(x, as.vector(x@data$NUMB))}
make.NUMB.sp.label <- function(x) {do.call("list", NUMB.sp.label(x))}
# Spplot
tps <- list(fontsize=list(text=5), fontcolor=list(text="green"))
trellis.par.set(tps)
spplot(mymap, "indic",
col.regions=c("#D3D3D3","#A9A9A9"),
sp.layout = make.NUMB.sp.label(mymap),
cex = 0.5,
bg = "white", col="light grey", border="light grey")