legend ticks/labels downscaling inconsistent
tm_shape(World) +
tm_polygons(fill = "gender",
fill.scale = tm_scale_continuous(values = "-hcl.cyan_magenta")) +
tm_bubbles(size = "pop_est") +
tm_compass() +
tm_scalebar() + tm_layout(scale = 0.4)
I've also encountered this issue today. Is there a workaround available? I've tried to change the text size of the legend, but with no effect...
@mtennekes I've tried a few scale values (e.g., 1 and 2) and it seems that the legend labels' size does not change with the different scale values. E.g., try 1 and 2 in the code below and notice that the size of the "missing" text is constant.
# remotes::install_github("r-tmap/tmap")
library(tmap)
data(World)
tm_shape(World) +
tm_polygons(fill = "gender",
fill.scale = tm_scale_continuous(values = "-hcl.cyan_magenta")) +
tm_bubbles(size = "pop_est") +
tm_compass() +
tm_scalebar() + tm_layout(scale = 1,
legend.position = c("left", "bottom"))
@Nowosad That's a tricker one, because the labels also have impact on the overal legend size. What happens under the hood by design:
- In advance the legend (or component) height and width are computed, taking scaling into account.
- If the required minimum height cannot be obtained, the legend/component is scaled down such that the layout does not change, at least that is the aim.
tm_shape(World) +
tm_polygons(fill = "gender",
fill.scale = tm_scale_continuous(values = "-hcl.cyan_magenta")) +
tm_bubbles(size = "pop_est") +
tm_compass() +
tm_scalebar() + tm_layout(scale = 4,
legend.position = c("left", "bottom"))
The fill legend does not fit, so it's scaled down. (To be consistent the border and tick marks should also not become thicker when following this approach).
A shorter legend will give room for the labels to grow:
tm_shape(World) +
tm_polygons(fill = "gender",
fill.scale = tm_scale_continuous(values = "-hcl.cyan_magenta", ticks = c(0.2,0.6))) +
tm_bubbles(size = "pop_est") +
tm_compass() +
tm_scalebar() + tm_layout(scale = 4,
legend.position = c("left", "bottom"))
What I could do is to let the labels still grow, even if they don't fit.
For now, it fixes my issue -- I will play with the tick argument. I do not have any strong suggestions here.
Not working correctly....
Not just oversized legends, but the general scale argument does not work well:
tm_shape(metro) +
tm_bubbles(
size = "pop2030") +
tm_layout(scale = 2)
Tokyo is less than 40mln but bubble suggests otherwise
The last issue is solved:
tm_shape(metro) +
tm_bubbles(
size = "pop2030") +
tm_layout(scale = 2)
Will close this issue now. All inconsistencies seem to be solved. Bubbles are still overlapping with tm_layout(scale = 4) but that is unavoidable.