-
Notifications
You must be signed in to change notification settings - Fork 118
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
Feature request: scale.values argument to tm_scale_* support flexible resizing. #877
Comments
Thanks for this question. Your solution may not be intuitive for the user, but surely helpful for me:-) The classes of the intervals scale are in principle independent of the breaks. (Because there is not one standard way to make a relation.) That explains the first legend: the sizes of the dots ( (in tmap jargon "values" of the scale) are from a squared scale from 0 to 1 (more specifically What you are probably looking for (please correct me if I'm wrong) is simply # Example 1
tm_shape(metro) +
tm_dots(size = "pop1950",
size.scale = tm_scale_intervals(breaks = c(0, 1, 2e5, 1e6, Inf), values = c(.5,1,2,3), values.scale = 0.3),
size.legend = tm_legend("City Category", frame = FALSE)) # Example 2
tm_shape(metro) +
tm_dots(size = "pop1950",
size.scale = tm_scale_continuous(values.scale = 1, limits = c(0, 1e6), outliers.trunc = c(TRUE, TRUE)),
size.legend = tm_legend("City Category", frame = FALSE)) # Example 3
tm_shape(metro) +
tm_dots(size = "pop1950",
size.scale = tm_scale_continuous(
values.scale = 1,
limits = c(0, 1e6),
ticks = c(5e4, 2e5, 5e5, 1e6),
labels = c("0 - 1", "1 - 200,000", "200,000 - 1,000,000", "1,000,000 or more"),
outliers.trunc = c(TRUE, TRUE)),
size.legend = tm_legend("City Category", frame = FALSE)) Created on 2024-05-14 with reprex v2.1.0 Let me know if this is any helpful and if you have further questions or suggestions. |
Thanks! Appreciate those examples, and would encourage you to include them in the documentation, e.g. of |
You're welcome. Good idea to add them to the examples! |
I have an interval scale of the form
The result is
Now I want the circle sizes to roughly reflect the city sizes. This does not seem possible using
values.scale
, which only controls the overall size. Passing a function such asscale.values = exp
or a vector of values of the same length asbreaks
would facilitate flexible resizing. Right now, the only way seems to define a new method for the multiplication operator:such that
yields
However, this is not elegant.
The text was updated successfully, but these errors were encountered: