首页 > 解决方案 > 在R中的ggplot中删除图例中的重复项

问题描述

我的图例中有一个烦人的重复数据和下面的代码,我正在努力删除:

ggplot(communitiesdata1, aes(`avg time to first response?`, `response rate`)) +
  geom_point(shape=21, 
             aes(fill=helpfulness, stroke=0.1,
                 colour = helpfulness,
                 size=`threads active in past 30 days`)) +  
  scale_fill_gradient2(high="red", low="blue", midpoint = mid) +
  geom_text_repel(aes(label=community,
                  ),
                  size = 3, # font size in the text labels
                  point.padding = 0, # additional padding around each point
                  box.padding = 0.3, # additional padding around each text label
                  ) +
  labs(title = "Community Category Performance - Jan 2021", 
       y = "Response Rate %", 
       x = "Avg. time to first response (mins)") + 
  theme_classic() + 
  theme(aspect.ratio = 1, axis.text=element_text(size=9), axis.title=element_text(size=9), plot.title = element_text(size=10, hjust=0.5), legend.title=element_text(size=7), 
    legend.text=element_text(size=6))

这给了我以下结果:

在此处输入图像描述

有谁知道如何删除图例中的重复项?我想删除第一个(浅到深蓝色渐变)

标签: rggplot2

解决方案


推荐阅读