I am working on a map showing regional population size changes (fill color) together with share of GDP (bubble sizes) in two separate years - 1995 and 2016 using tmap package and reading it into a .png file. Everything seems to work fine except that some of the bubble sizes seem to be off when compared with data.
I am reading the data from a .csv file. I have attached a screenshot of the data (there isn't much): figure data
The current plot looks like this: figure 23
As can be seen from the data, Tartu county is one of the few where GDP16 is larger than GDP95, however, the corresponding bubble on the chart looks smaller.
I have tried assigning the same aspect ratios and sizes for different layers but it does not seem to fix the issue. Not sure where to even look for the problem.
Here's my current code
library(sf) # classes and functions for vector data
library(raster) # classes and functions for raster data
library(tmap)
estonia <- st_read(dsn ="maakond_20190801.shp")
head(as.data.frame(estonia))
fig_data <- read.csv("fig_23_data.csv", header=TRUE, sep=";")
estonia$pop_change <- fig_data$pop_change
estonia$GDP95 <- fig_data$GDP95
estonia$GDP16 <- fig_data$GDP16
pop_change <- tm_shape(estonia) +
tm_fill("pop_change", title="Population change 1995-2016 (%)",
breaks = c(-30,-20, -10,0,10)) +
tm_borders(col="white") +
tm_layout(
outer.margins=0, asp=1920/1080,
legend.text.size=1,
legend.title.size=1.2,
legend.outside = FALSE,
legend.width=.2, legend.height=.6,
frame = FALSE)
GDP95 <- tm_shape(estonia) +
tm_bubbles(col = "#E6E3D9",alpha = 0.2, size = "GDP95", scale = 7, border.col="black", sizes.legend=c(2,10), title.size="Share of national GDP in 1995 (%)")+
tm_layout(outer.margins=0, asp=1920/1080)
GDP16 <- tm_shape(estonia) +
tm_bubbles(col = "#777777",alpha = 0.2, size = "GDP16", scale = 7, border.col="black", xmod=.4, sizes.legend=c(2,10), title.size="Share of national GDP in 2016 (%)")+
tm_layout(outer.margins=0, asp=1920/1080)
tmap_save(tm = pop_change + GDP95 + GDP16, filename = "figure2.png", dpi = 200)
png(filename="figure.png")
pop_change + GDP95 + GDP16
dev.off()
Any help would be appreciated!