【发布时间】:2019-08-21 17:42:47
【问题描述】:
请考虑以下代码:
library(ggplot2)
data<-mtcars
data$hp2<-mtcars$hp+50
data_long <- reshape2::melt(data[c('cyl', 'hp', 'hp2')], id.vars = 'cyl')
head(data_long)
ggplot(data_long, aes(x = cyl, y = value, colour = variable)) +
stat_summary(fun.y = mean, geom = "line", show.legend = FALSE) +
stat_summary(fun.y = mean, geom = "text", show.legend = FALSE, vjust=-0.7, aes( label=round(..y.., digits=0))) +
scale_color_manual(values = c("red", "blue"))
是否有可能改变红色曲线的文本标签行为? IE。显示在红线下方?
【问题讨论】: