Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panels: when to use (by default)? #941

Closed
mtennekes opened this issue Sep 26, 2024 · 3 comments
Closed

panels: when to use (by default)? #941

mtennekes opened this issue Sep 26, 2024 · 3 comments

Comments

@mtennekes
Copy link
Member

Related to #940

Panel labels can now always be turned off or on by the panel.show argument of tm_layout

The question for now: are you happy with these defaults?

library(tmap)
#> 
#> Attaching package: 'tmap'
#> The following object is masked from 'package:datasets':
#> 
#>     rivers
############################
###### Single map
############################
# default: no panels
tm_shape(World) +
    tm_polygons("HPI")

# with
tm_shape(World) +
    tm_polygons("HPI") +
    tm_layout(panel.show = TRUE)

############################
###### Facets defined with multiple variables
############################
# default: with panels
tm_shape(World) +
    tm_polygons(c("HPI", "footprint"))

# without
tm_shape(World) +
    tm_polygons(c("HPI", "footprint")) +
    tm_layout(panel.show = FALSE)

# default: with panels
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets("continent")

############################
###### Facets defined with multiple variables, single pages
############################
# default: without
tm_shape(World) +
    tm_polygons(c("HPI", "footprint")) +
    tm_facets_pagewise()

# with
tm_shape(World) +
    tm_polygons(c("HPI", "footprint")) +
    tm_facets_pagewise() +
    tm_layout(panel.show = TRUE)

############################
###### Facets defined with 'by' variable
############################
# default: with
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets("continent")

# without
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets("continent") +
    tm_layout(panel.show = FALSE)

############################
###### Facet grid
############################
# default: with panels
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets_grid("continent", "economy")

# without
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets_grid("continent", "economy") +
    tm_layout(panel.show = FALSE)

Created on 2024-09-26 with reprex v2.1.0

Imho, the only case in which panels could not be shown by default is the case of multiple variables (third image above). What do you think @Nowosad @Rapsodia86 @olivroy ?

I've also committed this script here https://github.com/r-tmap/tmap/blob/master/tests/testing_panels.Rmd

@Nowosad
Copy link
Member

Nowosad commented Sep 26, 2024

@mtennekes would not it be better if the tm_facets_pagewise also return the panel titles. I can think of two reasons for that:

  1. All of the facet types would return panel titles by default (so -- consistency)
  2. tm_facets_pagewise may be used for animations, and then panel titles are often neccesary

@Rapsodia86
Copy link

I agree with @Nowosad that consistency is important. Whenever any type of tm_facets_ is called, panels should to be visible. I would think that is a logical expectation.

But I understand you point in case of pagewise. Maybe then, move it to a separate function and name tm_pagewise() so maps are shown without a title as default?

In general, I do like the option to turn panels on/off regardless of a case! Great! Thank you very much:)

@mtennekes
Copy link
Member Author

Thx for your input @Nowosad and @Rapsodia86
I've changed the default: now panels are always visible.

A function tm_pagewise would be confusing I guess, same for tm_pages. (Because they are still facets, but printed on different pages.)

I also thought about adding a panel.show argument to tm_facets_x, but prefer not to, because this breaks the tmaps 'grammar of graphics' principles (tm_facets is just to define the facets, and has nothing to do with the plotting).

With the tm_layout(panel.show = FALSE) option it is good enough (otherwise feel free to reopen this issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants