Tmap: Allow size.max in tm_symbols (or tm_bubbles) to adjust the scaling of the symbol size

Created on 23 Feb 2020  路  2Comments  路  Source: mtennekes/tmap

```data(World, metro)
metro$growth <- (metro$pop2020 - metro$pop2010) / (metro$pop2010 * 10) * 100

tm_shape(World) +
tm_fill("grey70") +
tm_shape(metro) +
tm_bubbles("pop2010", col = "growth",
size.max=max(metro$pop2010)/2,
border.col = "black", border.alpha = .5,
style="fixed", breaks=c(-Inf, seq(0, 6, by=2), Inf),
palette="-RdYlBu", contrast=1,
title.size="Metro population",
title.col="Growth rate (%)") +
tm_format("World")
```

I want to be able to scale down the size of the symbols when I use a variable as the input value for size argument. The reason is that the symbols are overlapping each other even though the maximum size has defaulted to 1 and other sizes are scaled proportionally to 1. I want the maximum size to be smaller (e.g, 0.1). I tried giving size.max a new value (e.g., 0.5 or max(metro$pop2010)/2), but it does not scale down the symbol size. I also tried changing the variable values (e.g., dividing them by 100), but that does not change the symbol size as well. How can I scale down the symbol size when the argument for size is a variable?

(size.max=max(metro$pop2010)/2)
Screen Shot 2020-02-23 at 5 12 20 PM

(size.max=NA)
Screen Shot 2020-02-23 at 5 24 46 PM

(size.max=0.5)
Screen Shot 2020-02-23 at 5 21 11 PM

enhancement question

Most helpful comment

Thx for your question.

The scale argument is probably what you are looking for.

size.max determines the maximum of the range of values that are mapped to the bubbles. So, in this example, if you specify size.max = 100e6, the range [0, 100e6] is mapped to the bubbles, meaning that Tokyo with a population of 30e6, will be about 1/3 of the maximum bubble size.

Also size.lim might be interesting: it truncates values that are outside of a range. So if you would specify size.lim = c(0, 10e6). all cities with more than 10e6 population will be shown as if they have 10e6 population.

The actual bubble size that the largest value (i.e. size.max) represents, can be set with scale.

Please let me know if you understand how these arguments work, also from the description in the documentation.

All 2 comments

I find out how to work around it. So to scale down the size of symbols, people actually need to increase the value of size.max rather than decrease it. This is a counterintuitive setting, so I will leave it to the developers to decide if it should be changed.

Thx for your question.

The scale argument is probably what you are looking for.

size.max determines the maximum of the range of values that are mapped to the bubbles. So, in this example, if you specify size.max = 100e6, the range [0, 100e6] is mapped to the bubbles, meaning that Tokyo with a population of 30e6, will be about 1/3 of the maximum bubble size.

Also size.lim might be interesting: it truncates values that are outside of a range. So if you would specify size.lim = c(0, 10e6). all cities with more than 10e6 population will be shown as if they have 10e6 population.

The actual bubble size that the largest value (i.e. size.max) represents, can be set with scale.

Please let me know if you understand how these arguments work, also from the description in the documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jarsc568 picture jarsc568  路  8Comments

robsalasco picture robsalasco  路  4Comments

marionowak picture marionowak  路  9Comments

jannes-m picture jannes-m  路  5Comments

mtennekes picture mtennekes  路  4Comments