-
Notifications
You must be signed in to change notification settings - Fork 122
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
inconsistent legend behaviour #8
Comments
This was indeed desired, but I'm open to change it if it's counter intuitive. In this example, the main title is set to the fill variable, "pop_est_dens": tm_shape(World) + tm_fill("pop_est_dens") + tm_bubbles("gdp_md_est", col = "economy") Now, the main title is tm_shape(World) + tm_fill("pop_est_dens") + tm_bubbles("gdp_md_est", col = "economy") +
tm_layout("Main title") Now the main title is specified, as well as the legend title for fill: tm_shape(World) + tm_fill("pop_est_dens") + tm_bubbles("gdp_md_est", col = "economy") +
tm_layout("Main title", legend.titles=c(fill="population density")) |
Applied to your example: tm_shape(World) +
tm_fill() +
tm_shape(rivers) +
tm_lines(col="constant", palette="dodgerblue3") +
tm_shape(metro) + ## I replaced the cities dataset by metro
tm_bubbles(size=1, col = "constant") +
tm_layout("A map", legend.titles=c(bubble.col="Cities")) |
A problem may arise when multiple legend items will be supported [https://github.com/mtennekes/tmap/issues/2] The reason for this behavior was that most thematic maps will probably have only one legend element. For that element, it's overkill to have two titles (a main title and a legend title). A logical improvement could be that a legend title is only overruled by the main title if there is one legend element. |
OK, I didn't see there a |
Still a useful issue! I'll change it to make it more intuitive: in the next update, there will be a title argument for each aesthetic in each layer, and maybe other legend options as well. Only layout settings that are not legend-item-specific will be processed in tm_layout. |
Just started a "legends" branch for this. |
Done! Legend titles are now specified inside the layer functions, and the main title in tm_layout. |
Whether subtitles are used in the legend is not completely consistent.
Compare:
and
Maybe this is desired, but it can actually become a problem when there is more than one legend item:
The text was updated successfully, but these errors were encountered: