Consider this plot, which shows values ranging from 0.042
to 0.241
:
library(sf)
demo(nc, ask=FALSE, echo=FALSE)
brks <- seq(0, 0.2, by=0.05)
plot(nc["AREA"], key.pos=1, breaks=brks, at=brks)
However, let's say I need to customize the color key labels. I want add one "segment" to it in order to include values higher than 0.2.
For example:
brks2 <- c(seq(0, 0.2, by=0.05), 1)
plot(nc["AREA"], key.pos=1, breaks = brks2, at=brks2)
but the color key, rather than getting "stretched" from 0.2 to 1, should have just one more segment, with the label >0.2
or similar.
How can I do that?
We could add
.25
to the breaks, but I didn't find an option insf:::plot.sf
to create custom labels, so last label would be0.25
. Maybe you could setat=2
(to print the labels outside the window) and build a customaxis
and labels usingmtext
, but this becomes very cumbersome and inaccurate.It might, thus, be better to use
nbreaks=
. You could also play around withbreaks=
, where"pretty"
is default and other options are"fixed", "sd", "equal", "pretty", "quantile", "kmeans", "hclust", "bclust", "fisher", "jenks", "dpih", "headtails"
, see?sf:::plot.sf
.I think it's reasonable to address the author with a feature request, or maybe someone else is able to hack
sf:::plot.sf
.