r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
855 stars 119 forks source link

tmap option defaults & styles: your opinions? #906

Open mtennekes opened 1 month ago

mtennekes commented 1 month ago

(a follow-up from https://github.com/r-tmap/tmap/issues/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 ((https://github.com/r-tmap/tmap/commit/feae681edf16c7398d5cdc9377eafbc29436a170), 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:

My own answers (just an opinion):

What are your opinions?

Nowosad commented 3 weeks ago

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.

gilbertocamara commented 3 weeks ago

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!

nickbearman commented 3 weeks ago

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

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

marine-ecologist commented 2 weeks ago

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

ratnanil commented 2 weeks ago

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

mtennekes commented 1 week ago

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.

mtennekes commented 1 week ago

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

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

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()