I have a data frame that looks like the following only on a much larger scale called TA_population
TA_name | population | population_perc |
---|---|---|
Buller | 2376 | 28.59 |
Grey | 4653 | 55.98 |
Clutha | 1283 | 15.44 |
I am trying to create a Choropleth map with tmap with proportinal symbols where population_perc colours the area(TA_name) and then adding tm_bubbles which is the actual population.
This is the code I have got so far:
library(tmap) # plotting spatial data
library(tmaptools) # additional tools for map making
# plotting
tmap_mode("plot")
# defining breaks and labels for pop_perc
brks1 <- c(0,0.5,1,2,5,10,20,40)
labs1 <- c("0\u20130.5","0.5\u20131","1\u20132","2\u20135","5\u201310","10\u201320","20\u201340")
tm_shape(TA_population) +
tm_polygons(col = "population_perc",
palette = "Reds",
breaks = brks1,
labs = labs1,
border.alpha = 0.2,
n = 7,
title = "Population Percentage by TA's (%)") +
tm_shape(TA_population) +
tm_bubbles(size = "population",
col = "black",
alpha = 1,
title.size = "Population") +
tm_compass(position = c("right", "top"),
size = 1.5,
show.labels = T,
color.light = "black") +
tm_scale_bar(position = c("right", "bottom"),
breaks = c(0,100,200)) +
tm_credits("Data: Census 2018, (c) StatsNZ",
position=c("right", "bottom"), # placement
size = 0.8) +
tm_layout(bg.color = "lightcyan",
frame = T,
legend.position = c("left","top"), # legend position
title = "Population Percentages of South Island TA's",
title.size = 1,
title.fontface = "bold",
legend.title.size = 0.8,
legend.text.size = 0.6)
and this is what it produces:
How would I go about adjusting the breaks and labels for tm_bubbles hence maybe change it to intervals like (0,25000,50000,100000,200000,400000) without them overlapping an being over top of each other. I tried to do a similar thing as I did in the tm_polygons section, however it didn't work.