我使用 ggplot 和 geo_bar 来生成一个图,结果是这样的:
代码
# Faceting is a good alternative:
ggplot(df.cnts, aes(x=date,y=freq)) + geom_bar(stat="identity") +
facet_wrap(~ operator, nrow = 3) +
theme(axis.text.x = element_text(angle=90, vjust=0.5, size=8))
题
我可以编写代码来为值大于 1000 的所有条形着色吗?
谢谢
最佳答案
mt_mean <- mtcars %>% group_by(cyl) %>% summarise(avg_mpg = mean(mpg) )
ggplot( mt_mean , aes(x=cyl, y =avg_mpg)) +
geom_bar(stat = 'identity', aes(fill = avg_mpg > 25 ) )
g + scale_fill_manual(values = c('red', 'black') )
关于r - ggplot geom_bar 如果值高于阈值,我可以突出显示不同颜色的条吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28178495/