tmap icon indicating copy to clipboard operation
tmap copied to clipboard

Suggestion: sd style labels

Open Nowosad opened this issue 5 years ago • 1 comments

@mtennekes I have three ideas for improvement of the sd style. Let me know what you think about it.

  1. Automatic labels for this style (how much the values deviates from the mean) (see image at the bottom)
  2. Middle class containing the values around the mean (e.g. -0.5 sd to 0.5 sd). Right now, there are two middle class - one below and one above the mean.
  3. Automatic diverging palette when the sd style is used.
library(tmap)
library(spData)

mean(world$lifeExp, na.rm = TRUE)
#> [1] 70.85439
sd(world$lifeExp, na.rm = TRUE)
#> [1] 8.209522

tm_shape(world) +
  tm_polygons("lifeExp", style = "sd")
#> Linking to GEOS 3.8.1, GDAL 3.0.4, PROJ 6.3.2

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

Nowosad avatar Oct 09 '20 09:10 Nowosad

I forgot about this one.

Very interesting, and for v4 low-hanging fruit. All we have to do is add another 'style' option in tm_scale_intervals.

We only have to think about the title and legend labels. For the title, we can add " (deviation from mean)" or "(\nDeviation from Mean)", but for the legend items it is tricker: the 'suffix' argument of label.format in tm_scale_x is meant for numbers rather than intervals. Perhaps a new argument to the label.format list? (Which should ideally be tm_label_format(), but I'll leave that for another time.

mtennekes avatar Dec 30 '24 23:12 mtennekes