How to manipulate tmap legend?

后端 未结 1 1158
长发绾君心
长发绾君心 2021-01-31 21:02

I\'m creating a thematic map of percent change per year for bird species. here is the code I have:

tm_shape(grid83)+
  tm_fill(\"trend\", title = \"Percent chang         


        
1条回答
  •  北海茫月
    2021-01-31 21:19

    So you are trying to change the color specifically for NA values? The colorNA argument to tm_fill() serves that purpose.

    Here's an example:

    library(tmap)
    data(Europe)
    tm_shape(Europe) +
    tm_fill("gdp_cap_est", title = "GDP", style = "fixed",
            breaks = c(0, 10000, 20000, 30000, 40000, Inf),
            textNA = "Dunno", 
            colorNA = "green",   # <-------- color for NA values
            palette = c("red", "orange", "yellow", "turquoise", "blue", "white")) +
    tm_borders() +
    tm_layout("Wealth (or so)",
              legend.title.size = 1,
              legend.text.size = 0.6,
              legend.position = c("left","bottom"),
              legend.bg.color = "white",
              legend.digits = 5,
              legend.bg.alpha = 1)
    

    It looks like this:

    0 讨论(0)
提交回复
热议问题