When trying to plot a dotmap with tmap:


I want the points to remain at their original scale, but want the symbols in the legend to be larger, as right now they are the same size of the individual dots and thus very hard to see. If possible, I'd like to have them in rectangles.

Map with legend, legend points are too small

This is how summary() on my dataset looks like:

   Party                    geometry    
 Length:61457       POINT        :61457  
 Class :character   epsg:3006    :    0  
 Mode  :character   +proj=utm ...:    0  
  • What if you use tm_legend(scale=2)? – Chelmy88 Aug 19 '19 at 12:28
  • This changes the scale of the dots in the map as well. – Kenji Aug 19 '19 at 12:37
  • And if you put scale=1 in tm_dots() (and keep the scale=2) – Chelmy88 Aug 19 '19 at 12:39
  • The map always matches the larger number passed to scale, regardless of whether it is inside tm_dots or tm_legend. – Kenji Aug 19 '19 at 12:42
  • I can't replicate this with sample data from the package, eg tm_shape(metro) + tm_dots(col="pop1950") using metro from ?tm_dots. Dots on map and dots on legend are different and okay sizes. Can you edit and include an image? Or show summary of your data? – Spacedman Aug 19 '19 at 15:45

By design, the symbols in the legend are as close to the symbols in the map as possible.

If you want the legend to be different, one approach is to create a manual legend:

tm_shape(World) +
    tm_fill("black") +
    tm_dots("footprint", size = .1, legend.show = FALSE) +
    tm_add_legend(type = "fill", 
                  col = c(tmaptools::get_brewer_pal("YlOrRd", 4, plot = FALSE), "grey75"),
                  labels = c("0 to 5", "5 to 10", "10 to 15", "15 to 20", "Missing"),
                  title = "Footpritn")

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.