最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

I can not remove the missing value label in the legend portion from my tmap in R - Stack Overflow

programmeradmin3浏览0评论

I am trying to visualize percentage of anaemia patients using a map and successfully done it. The problem I am facing I can not remove the missing value category from the legend of the map. In my dataset, there is no missing value as I omitted those during the data processing part. I have used sf package to read the shape file and tmap package for visualizing map. I have attached my codes and map in this question.

map = data_joined_with_shape_file %>%
  select(NAME_2, Anaemia, geometry) %>% 
  tm_shape()+
  tm_polygons("Anaemia", breaks = c(0, 25, 30, 40, 50, 60),
              palette = c("white","#f7fbff", "#9ecae1", "#6baed6", "#4292c6", "#08519c"))

Overall = map + 
  tm_shape(data_joined_with_shape_file %>% filter(Anaemia > 20))+
  tm_text("NAME_2", size = 0.95,
          fontfamily = "serif", just = "center", fontface = "bold")+
  tm_layout(legend.position = c("right", "top"),
            frame = FALSE,                          # Remove map frame
            legend.text.size = 1.3,                 # Reduce legend text size
            legend.title.size = 2,                  # Reduce legend title size
            legend.bg.color = NA,                   # Remove legend background
            legend.bg.alpha = 0,                    # Ensure transparency
            legend.na.show = FALSE,
            legend.title.fontface = "bold",
            legend.text.fontfamily = "serif",
            legend.title.fontfamily = "serif",
            legend.frame = FALSE)                   # Remove legend frame
[![Anaemia Map](.png)](.png)

I want to remove the Missing label from the legend of this map.

发布评论

评论列表(0)

  1. 暂无评论