r-tmap/tmap

tmap option defaults & styles: your opinions?

mtennekes opened this issue · 7 comments

(a follow-up from #593)

Before v4 can be released on CRAN, we need to make sure all the default values for the options and (closely related) all the styles are intuitive to use.

There are over 600 options in tmap4, but I am talking about the most important ones from a user perspective: default colors, color scales, font sizes, legend frames, etc.

I've made some changes to the default option values, most importantly:

This set of default option values is known by tmap4 as the style "white".

> tmap_style()
current tmap style is ""white" (tmap default)
other available styles are: "gray", "natural", "cobalt", "albatross", "beaver", "bw", "classic", "watercolor"
tmap v3 styles: "v3" (tmap v3 default), "gray_v3", "natural_v3", "cobalt_v3", "albatross_v3", "beaver_v3", "bw_v3", "classic_v3", "watercolor_v3"

So far ((feae681), all the other styles have been copied directly from v3. For each style, say "cobalt" there is a new version (also called "cobalt"), that takes all color (palette) options but with the new tmap4 changes (e.g. legends), and a version named "cobalt_v3"that replicates this style as close as possible to this style in tmap3.

Please run and check the output of

tmap_style_catalog()

I'd like to remain all v3 styles (iIncluding "col_blind_v3" that is still missing) for backward compatibility.

Questions for you:

  • Which existing styles ("gray", "natural", "cobalt", "albatross", "beaver", "bw", "classic", "watercolor") do you find useful and why?
  • What defaults would you like to change (colors, palettes, etc) for which style?
  • Which existing style do you find useless, and can be dropped?
  • Do you have other ideas for styles?

My own answers (just an opinion):

  • My favourites: classic, natural, cobalt
  • "bw": the only option that is set here is color.intensity = 0. So all color palettes except sequential are useless here and need to be changed.
  • The style "gray" was a default the same "white" but only with a gray background. Not sure I ever used it.... "watercolor" is only useful when using the "view" mode. "albatross" is similar to "cobalt" but I like it less.

What are your opinions?

Hi @mtennekes -- I mainly use the default style, so I do not have strong feelings about other styles. The "bw" one is also nice, as it may show how the map will look when printed.

Dear @mtennekes, we have now transitioned in sits from version 3 to version 4. The new API is much better. There only one glitch: when legends are shown outside the map, the map is shrunk significantly. For interactive displays such as working with RStudio, this is not the ideal solution. However, I cannot see a good fix for the problem other than using legends inside the map.

All in all, kudos for your excellent work!

the position of the legend (now outside) and its design

I think the legend being outside by default is a great improvement, thanks!

Hi @mtennekes - almost exclusively use the default style as well, but appreciate the variety of alt options to diversify tmap!

I was unaware of the availability of themes, but will definitely test them in the future 🙏🏼

Dear @mtennekes, we have now transitioned in sits from version 3 to version 4. The new API is much better. There only one glitch: when legends are shown outside the map, the map is shrunk significantly. For interactive displays such as working with RStudio, this is not the ideal solution. However, I cannot see a good fix for the problem other than using legends inside the map.

All in all, kudos for your excellent work!

Thx for this useful feedback. Imho, the pros of having the legend outside the map outweighs the cons. The layout of the plot (map(s) with components such as legends) should be (near) optimal given the device size. In case you encounter a situation in which the layout is far from optimal, please let me know with a screenshot.

FYI: I have updated the default color palettes for categorical data.

I've created several new palettes in the underlying package cols4all:

  • area7, area8, and area9 are light medium-saturated palettes that are color-blind-friendly, and should work well against a white background
  • area7d, area8d, and area9d same but for a dark background
  • line7, line8 and line9 are more saturated color palettes. The contrast ratio with both white and black is sufficient for text and lines (according to WCAG standards).

area7 will be the new default for fill and line7 for col. The only exception is tm_dots where fill is set to line7.

tm_shape(World) + 
  tm_polygons("economy") + tm_title("c4a.area7 palette")

image

tm_shape(rivers) + 
  tm_lines("scalerank", lwd = 2, col.scale = tm_scale(values = "cat")) + 
  tm_title("c4a.line7 palette")

image

Have to work on standard 'dark' theme. At the time being:

tm_shape(World) +
  tm_polygons("economy", col = "grey70", 
    fill.scale = tm_scale_categorical(values = "area7d")) + 
  tm_title("c4a.area7 palette") + tm_style("cobalt") +
  tm_options(bg.color = "black", outer.bg.color = "black")

image

Because these new palettes are in the dev-version of cols4all (not the CRAN version), these palettes are for the time being also loaded directly in tmap (in onLoad), so the startup time of tmap is a bit slower.

If you are interested in these color palettes, please check out the gui:

remotes::install_github("mtennekes/cols4all")
library(cols4all)
c4a_gui()