ggplot2删除两个图例中的一个

时间:2016-09-23 18:40:43

标签: r ggplot2

我按照下面链接的一般结构将两个geom_boxplot绘制在彼此的顶部,最终目标是让一个箱形图的胡须破灭。我成功了,但现在我认为有两个传说与每个箱图相对应。

How to modify whiskers of a boxplot in ggplot2?

How to customize whisker lines on a geom_box plot differently than the lines of the box itself

enter image description here

t = ggplot(data = graph_data) +
    geom_boxplot(aes(x = data_source, ymin = lwo, lower = pct_25, middle = median, 
                     upper = pct_75, ymax = uwo, fill = data_source, linetype = data_source), 
                     stat = 'identity', color = 'black') +
    geom_boxplot(aes(x = data_source, ymin = pct_25, lower = pct_25, middle = median, 
                     upper = pct_75, ymax = pct_75, fill = data_source), 
                     stat = 'identity', color = 'black') +
    geom_text(aes(x = data_source, y = -Inf, label = count_label),
                vjust=-.5,stat='identity',size = 3,colour='Black',fontface='italic') +
    theme_custom +
    facet_grid(. ~ month, labeller = labeller(month = month_lbls)) + 
    theme(strip.background = element_rect(fill = NA)) +
    theme(strip.text = element_text(size = rel(1.0), face = "bold")) +
    scale_fill_manual(values = as.character(graph_colors), labels = names(graph_colors), guide = guide_legend(title = "Data Source")) +
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
    theme(panel.margin = unit(3, "points")) +
    theme(panel.grid.major.x = element_blank()) +
    theme(panel.grid.minor.x = element_blank())

在第一个geom_boxplot中,我指定了不同的line_type,然后用实线覆盖第二个geom_boxplot中的四分位数范围。我认为这两个boxplot的添加创建了两个传说,关于如何删除顶级图例的任何想法(标题为' data_source')?

0 个答案:

没有答案