I am plotting some spatial data in R using the tmap
package. I define breaks and plot color in the tm_dots
function. I'd like to be able to define the plot order of the categories so that they are defined by the category (highest category on top, second highest below that, etc.). I need to be able to see clearly where the highest category points are. I know this could be achieved with multiple spatial point data frames, but is there another less clunky way? Below is an example using the meuse data. I make the points huge so they overlap. So ideally here in the plot the plot order would be: blue, green, orange, red.
libary(tmap)
library(sp)
data("meuse")
coordinates(meuse) <- c("x","y")
tm_layout() +
tm_shape(meuse) + tm_dots("cadmium", breaks = c(1,2,3,4,Inf), palette = "-Spectral", auto.palette.mapping = FALSE,
size = 1) +
tm_legend(legend.outside = TRUE)