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

Non-overlapping legend intervals #399

Closed
pbpearman opened this issue Mar 4, 2020 · 3 comments
Closed

Non-overlapping legend intervals #399

pbpearman opened this issue Mar 4, 2020 · 3 comments

Comments

@pbpearman
Copy link

I love this package, but I refer you to this post
There should be some straightforward way to specify non-overlapping legend intervals automatically, as requested in the post. If it's not simply a case of me not seeing how to do this (if so, please enlighten me), can you please develop a feature to accomplish what the posted question requests: straightforward, dynamic, non-overlapping legend intervals? Manually specifying labels is tedious. The default should be non-overlapping intervals, since overlapping value ranges are inherently ambiguous.

@mtennekes
Copy link
Member

I don't understand. The default intervals are non-overlapping, or do I miss something?

The default interval notation ("10 to 20", "20 to 30") may not be clear. Suggestions welcome. In scientific mode:

data("World")
tm_shape(World) +
    tm_polygons("HPI", n = 7, legend.format = list(scientific = TRUE, format = "f"))

returns the commonly used notation, which is [ for closed and ( for open. So [20, 25) means 20 to 24.999999999. You can set begin of the interval to open and the end to closed, so (20, 25], with interval.closure. See

tm_shape(World) +
    tm_polygons("HPI", n = 7, legend.format = list(scientific = TRUE, format = "f"),
        interval.closure = "right")

@mtennekes
Copy link
Member

mtennekes commented Mar 11, 2020

Peter, I just read your comment in the SO answer. Sorry mate, but I don't agree with you that the [a, b) notation is non-standard.

If I understand you correctly, do you mean "10 <= HPI < 20" ?

@Nowosad
Copy link
Member

Nowosad commented Apr 26, 2020

There is a new improvement in this area with tmap > 3.0. More examples are at https://github.com/mtennekes/tmap/issues/406#issuecomment-610559092.

library(tmap)
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 7.0.0
data("World", package = "tmap")

World$x <- sample(0:20, size = 177, replace = TRUE)
tm_shape(World) + tm_polygons("x")

Created on 2020-04-26 by the reprex package (v0.3.0)

@Nowosad Nowosad closed this as completed Apr 26, 2020
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