【问题标题】:Is there a function to alter the legend to match the buffers I have created?是否有更改图例以匹配我创建的缓冲区的功能?
【发布时间】:2021-11-08 09:39:23
【问题描述】:

我创建了 2 个 250m 和 500m 的缓冲区。当我绘制我的数据时,它显示我的图例有太多 Summarising population in buffers

我希望图例有 0-250、250-500,然后超过 500,并且缺少数据

【问题讨论】:

    标签: plot buffer legend tmap


    【解决方案1】:

    我不确定我是否理解这个问题,因为您没有提供可重现的示例,但我认为以下内容会有所帮助:

    tm_polygons() 函数中使用 breakslabels 参数。

    nc = st_read(system.file("shape/nc.shp", package="sf"))
    
    Breaks <- c(0, 2000, 4000, 6000, 31000)
    Labels <- c("0 - 2000", "2000 - 4000", "4000 - 6000", ">6000")
    MyPalette <- c("#f2f0f7", "#cbc9e2", "#9e9ac8", "#6a51a3")
    
    tm_shape(nc) + 
      tm_polygons(col="BIR79", title = "Births 1979 - 84", palette = "YlGnBu",
              breaks = Breaks, labels = Labels)
    
    tm_shape(nc) + 
      tm_polygons(col="BIR79", title = "Births 1979 - 84", palette = MyPalette,
              breaks = Breaks, labels = Labels)
    

    【讨论】:

      最近更新 更多