tmap tm_bubble 大小不正确

tmap tm_bubble sizes incorrect

我正在制作一张地图,显示区域人口规模变化(填充颜色)以及两个不同年份(1995 年和 2016 年)的 GDP 份额(气泡大小),使用 tmap 包并将其读入 .png 文件。一切似乎都很好,除了一些气泡大小与数据相比似乎不对。

我正在从 .csv 文件中读取数据。我附上了数据的截图(不多):figure data

目前的情节是这样的: figure 23

从数据中可以看出,塔尔图县是少数GDP16大于GDP95的县之一,但图表上对应的气泡看起来更小。

我试过为不同的图层分配相同的纵横比和大小,但似乎无法解决问题。甚至不知道在哪里寻找问题。

这是我当前的代码

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()

如有任何帮助,我们将不胜感激!

好的,我暂时解决了:

tm_bubbles 层似乎是分开工作的,因此两个层的最高值大小相同(如果比例相同),其余值是相对于它们的大小。

只需将第一层的比例乘以等于数据集中最高值之间比率 (54.1/64) 的系数,即可给出气泡的正确相对大小。