riatelab / cartography

Thematic Cartography for R
http://riatelab.github.io/cartography/docs/
397 stars 46 forks source link

Symbols sizes in the legend. #77

Closed rCarto closed 3 years ago

rCarto commented 3 years ago

Received by e-mail:

"In the construction of proportional symbols such as circles, there is a clearly a default classification into the smallest, largest and then two other intervals to establish four circle sizes apparent in the legend. I did think it was an equal interval classification, but the numbers don't match. Can you tell me how these are determined?"

The default values for proportional symbols are the smallest, the largest and two others that correspond to symbols of intermediate radii (equal intervals of radii not values).

If you want to set the reference values in the legend yourself you have to use legendCirclesSymbols().

library(cartography)
library(sf)
#> Linking to GEOS 3.7.1, GDAL 3.1.2, PROJ 7.1.0
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"), quiet = TRUE)
plot(st_geometry(mtq))
propSymbolsLayer(x = mtq, var = "POP")

plot(st_geometry(mtq))
propSymbolsLayer(x = mtq, var = "POP", 
                 legend.pos = NA, 
                 inches = .3)
legendCirclesSymbols(pos = "topright", 
                     var = c(686,15000, 40000,82502), 
                     inches = .3)

Created on 2020-11-09 by the reprex package (v0.3.0)

You have to make sure that the inches argument in propSymbolsLayer() and legendCirclesSymbols() is set to the same value and that the maximum value of the var argument of legendCirclesSymbols() matches the maximum value of the variable (or the fixmax value in propSymbolsLayer() if used.)

I hope this clarify.