这是indexloc提供的服务,不要输入任何密码
Skip to content

adds v4 vig improvements #592

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

Merged
merged 1 commit into from
Aug 28, 2021
Merged

adds v4 vig improvements #592

merged 1 commit into from
Aug 28, 2021

Conversation

Nowosad
Copy link
Member

@Nowosad Nowosad commented Aug 28, 2021

Hi @mtennekes,
I read and also tried to improve the vignette (see my changes in the PR). Additionally, I have a few comments/questions:

  1. Functions such as tm_legend have not got any documentation. I assume that will change in the future? (Documentation would allow me to explore the possible options)

  2. There is the tm_lp_out and tm_lp_inset functions. Would not it be easier to remember if the second function is tm_lp_in?

  3. Is tm_layout dead/removed in tmap v4 and the users should switch to tm_options? Why did you decide to change tm_layout to tm_options?

  4. I commented out a paragraph in the Facets sections that I was not able to understand...

  5. You had specified colors with tmap_pals$pals.brewer$brewer.greens. Is that the final syntax, or would it be able to call palettes just with "brewer.greens"?

  6. What is the difference between meta.margin and inner.margin/outer.margin?

I also tried to run the code in sandbox/main2.R. They are very interesting. My comments:

  1. Legends - there is still an issue with too wide space for the outside legend (e.g., see an example in line 318)

  2. Continuous legends - I think it would be great to (a) add legend ticks, (b) add some examples of horizontal legends (e.g., I would love to be able to easily create a horizontal legend at the bottom that would occupy the total map width)

Best,
J

@mtennekes mtennekes merged commit b951707 into v4 Aug 28, 2021
@mtennekes
Copy link
Member

mtennekes commented Aug 28, 2021

Thanks for these helpful issues @Nowosad !

  1. Yes, definitely. Haven't had time to do documentation at all, and if moreover, I should start with documenting the code itself first.
  2. Good point! What do you think of tm_lp? As you may have guessed, the lp stands for legend position. Do you have other alternatives as tm_legend_position_out is probably a bit too long?
  3. No, that is an (understandable) misunderstanding: in the current framework, there is still room for a tm_layout, but a little differently from a developers perspective:
    History: tm_layout existed before there tmap_options, and even before there was a view mode. The idea behind tmap_options was (and still is) that users should be able to set layout settings globally. However, as tmap matured, more and more options were added, including options that were not (directly) related to the layout. I introduced tm_view to set options that were (only) related to the view mode. But even then there were still options that had nothing to do with layout (e.g. max.raster and show.warnings.)
    v4 idea: there will be a tm_options, by which users are able to set any tmap option, so identical with tmap_options. However, tm_options is meant for experienced users, simply because many options are quite complex (and cannot be made easier due to the complexity of the tmap framework). That is exactly the task of user-friedly wrapper functions such as tm_place_legend_left. Also tm_layout will be a wrapper of tm_options. I expect that it will be used the same as in v3, but only with the relevant arguments (regarding titles, panels, background color, frame, etc). The options such as the default palettes (aes.palette) will be deprecated and only available via tm_options (in another form since the whole framework has changed under the hood).
  4. In a facet grid, there are rows and colums. A scale can be applied for 1) each facet 2) each row, 3) each column and 4) all facets together. I will elaborate more in this in our video call. Probably this feature will not be used often.
  5. Yes, brewer.greens work, but the philosophy behind tmap_pals$pals.brewer$brewer.greens is that users can browse through the palettes using RStudio's auto-completion. I am not completely happy yet with the color system in tmap v4. For instance the palette "Greens" will refer to the hcl one and not the ColorBrewer one. The fact that they use slightly different colors is not a big issue, but the fact that the hcl palettes start with the dark color is a big issue for backwards compatibility. Ideas on this are welcome.
  6. inner.margin is between the map and the frame, outer.margin is between the device edges and the plot area. meta.margins are the margins that are used for the "meta data", most importantly the legends.

1 The meta.margins are set automatically based on the occurrence of legends, however not on the content of the legends themselves (which is too complicated). I still have to play around with the default settings. I don't have implemented landscape legends yet (of course I will). The availability of landscape legends will make it possible to use the space more efficiently. For example: if the aspect ratio of the device is larger (so more landscapish) than the bounding box, then place the legends at the bottom. If (in that case) the aspect rations are not very different, use landscape legends (stacked vertically), and otherwise (so if there is much room below the map) use portrait legends stacked horizontally.

2 a) good idea to add ticks. b) will do (once implemented)

@Nowosad
Copy link
Member Author

Nowosad commented Aug 29, 2021

Thanks for all of the explanations.

2. Good point! What do you think of `tm_lp`? As you may have guessed, the lp stands for legend position. Do you have other alternatives as `tm_legend_position_out` is probably a bit too long?

tm_legend_in() and tm_legend_out() comes to my mind as possible alternatives...

3. No, that is an (understandable) misunderstanding: in the current framework, there is still room for a `tm_layout`, but a little differently from a developers perspective:
   **History**: `tm_layout` existed before there `tmap_options`, and even before there was a view mode. The idea behind `tmap_options` was (and still is) that users should be able to set layout settings globally. However, as tmap matured, more and more options were added, including options that were not (directly) related to the layout. I introduced `tm_view` to set options that were (only) related to the view mode. But even then there were still options that had nothing to do with layout (e.g. `max.raster` and `show.warnings`.)
   **v4 idea**: there will be a `tm_options`, by which users are able to set any tmap option, so identical with `tmap_options`. However, `tm_options` is meant for experienced users, simply because many options are quite complex (and cannot be made easier due to the complexity of the tmap framework). That is exactly the task of user-friedly wrapper functions such as `tm_place_legend_left`. Also `tm_layout` will be a wrapper of `tm_options`. I expect that it will be used the same as in v3, but only with the relevant arguments (regarding titles, panels, background color, frame, etc). The options such as the default palettes (`aes.palette`) will be deprecated and only available via `tm_options` (in another form since the whole framework has changed under the hood).

It makes a lot of sense. I like this trimming of tm_layout().
Two additional things: (1) why tm_place_legend_left and not tm_place_legend("left"), and (2) are you not afraid that making similar functions, such as tm_lp_inset and tm_place_legend_left could confuse users? Would it be possible, for example, to just have, e.g., tm_legend_in("left") or tm_legend_in("left", "top") which would work similar to both tm_lp_inset and tm_place_legend_left (the latter function could be then removed)?

@Nowosad Nowosad deleted the v4add branch August 29, 2021 07:33
@mtennekes
Copy link
Member

pals_bivariate

(using it as placeholder for the vignette)

T.b.c.

@mtennekes
Copy link
Member

I've updated the vignette. Please take a look @Nowosad I made some minor changes, so the code in main.r and main2.r may not work anymore (haven't tested yet).

As a user, I find tm_place_legend_left easier (i.e. faster) to type (using auto-completion) then tm_place_legend("left"). But we can easily change this.

We already have the tm_legend_ functions, which currently include tm_legend_landscape, tm_legend_portrait, tm_legend_hide, and tm_legend_combine, so tm_legend_in and tm_legend_out might be confusing, at least for the legend position argument. We can also decide to put tm_legend_in on a similar level as tm_legend_landscape, but then we'll also need cross-categories, e.g. tm_legend_landscape_in.

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

Successfully merging this pull request may close these issues.

2 participants