-
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
New feature: a multiple-column legend #829
Comments
It is definitely possible to implement, but it does take quite some time. I am currently focussed on getting v4 on CRAN, so this has lower priority for me. To help you out, there is a manual workaround: library(tmap)
tm_shape(World) +
tm_polygons("HPI") pal = cols4all::c4a("hcl.blues3", n = 7)
palna = cols4all::c4a_na("hcl.blues3")
tm_shape(World) +
tm_polygons("HPI", fill.legend = tm_legend_hide()) +
tm_add_legend(labels = c("10 to 15", "15 to 20", "20 to 25", "25 to 30"), fill = pal[1:4], type = "fill", title = "HPI") +
tm_add_legend(labels = c("30 to 35", "35 to 40", "40 to 45", "Missing"), fill = c(pal[5:7], palna), type = "fill", title = " ", stack = "horizontal") Created on 2024-02-15 with reprex v2.1.0 |
Thanks very much @mtennekes . I've tried this workaround in v3.99.9000 which was installed by the following code: An issue still occurs when the colour palette is changed. The colour of the manually added legend is inconsistent with the colour in the map, whatever the palette changes. Examples are as follows (for simplicity, missing values are ignored). e.g. 1:
e.g. 2:
I'd appreciate your suggestions. |
@taozhou2020, you also need to update the palette of the main (not only the legend) -- I think that part should like something like:
|
@Nowosad, Thanks for your help. It works now, and it also works perfectly with
|
It appears that creating a legend with multiple columns has not yet been possible, but would be a nice-to-have feature. Will this be achieved in future versions?
The text was updated successfully, but these errors were encountered: