【问题标题】:Remove slashes from ggplot2 legend using geom_histogram使用 geom_histogram 从 ggplot2 图例中删除斜线
【发布时间】:2015-11-11 23:29:21
【问题描述】:

如何从图例中删除斜线?

ggplot(data, aes(y, fill = factor(x))) +
geom_histogram(colour = "black", position = 'identity') +
theme(legend.position="top", legend.title=element_blank()) +
scale_fill_manual(values = c(rgb(11,61,145, maxColorValue=255), "white",         rgb(252,61,33, maxColorValue=255))) +
scale_y_continuous("Count") +  
scale_x_continuous("Age") + 
theme(axis.text.x = element_text(face="bold", color="#252525", size=12),
  axis.text.y = element_text(face="bold", color="#252525", size=12)) 

谢谢。

【问题讨论】:

标签: r ggplot2 legend


【解决方案1】:

这对你有用吗?

library(ggplot2) 
set.seed(6667)
diamonds_small <- diamonds[sample(nrow(diamonds), 1000), ]
ggplot(diamonds_small, aes(price, fill = cut)) +
       geom_density(alpha = 0.2)  +  
       guides(fill = guide_legend(override.aes = list(colour = NULL)))

使用来自http://docs.ggplot2.org/current/geom_histogram.html的示例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-07
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多