【发布时间】:2018-01-31 14:51:51
【问题描述】:
我是 ggplot 新手,从这张图开始:
library(ggplot2)
library(reshape2)
data <- read.delim(textConnection("
Sample Day_0 Day_1 Day_4 Day_5 Day_7
NM 1000 221000 6620000 17200000 43700000
OG 1000 351000 1750000 6880000 18300000
OD 1000 961000 1090000 6380000 4400000
ODD 1000 1060000 3550000 12000000 13100000"), sep = " ")
data_melt <- melt(data, id.var = "Sample")
data_melt$value <- as.numeric(data_melt$value)
ggplot(data=data_melt, aes(x=variable, y=value, color = Sample)) + geom_point(size = 2.5) + scale_y_continuous(trans=log2_trans(), breaks = trans_breaks("log10", function(x) 10^x), labels = trans_format("log10", math_format(10^.x))) +
ggtitle("My_Title") + xlab("My_X") + ylab("My_Axis") + theme(plot.title = element_text(hjust = 0.5)) + expand_limits(y = c(10^3, 10^8))
我想做的是添加每个“天”的 4 个点的平均值和误差线(in this kind of way for example,图片来自http://www.sthda.com/)。
任何方法/建议都会有所帮助!
【问题讨论】: