1
我想有误差条线图。线图和误差条
我有数据如下:
data <- read.table(text = "servers Throughput Error Protocols
3 3400 3.45 Z1
5 2300 3.45 Z1
7 1700 3.45 Z1
9 1290 3.45 Z1
3 5000 1.064564 Z2
5 2500 1.064564 Z2
7 1800 1.064564 Z2
9 1400 1.064564 Z2
3 4500 1.064564 Z3
5 2490 1.064564 Z3
7 1780 1.064564 Z3
9 1370 1.064564 Z3", header = TRUE)
脚本绘制折线图和误差线如下:
data$servers <- as.factor(data$servers)
plot1 <- ggplot(data=data , aes(x=servers, y=Throughput, group=Protocols, colour = Protocols, shape=Protocols)) +
geom_errorbar(aes(plot1,ymin=Throughput-Error, ymax=Throughput+Error) +
geom_line() +
geom_point(size=3)
plot1 <- plot1 + scale_y_continuous(breaks= seq(0,5500,500), limits = c(0,5500)) +
labs(x="size") +
scale_x_continuous(breaks = c(3, 5, 7,9)) +
labs(y="Throughput (ops/sec)")
plot1 <- plot1 + scale_colour_manual(values=c("#66CC99","#997300", "#6c3483"))
plot1 <- plot1 + theme_bw() +
theme(legend.position="bottom") +
labs(fill="", colour=" ", shape=" ") +
theme(text = element_text(size=18)) +
guides(fill = guide_legend(keywidth = 0.8, keyheight = 0.01))
plot1
的问题是,该错误栏不会出现。
任何帮助?
试好。但是,如何使错误栏垂直?原因错误条与y轴相关而不是x轴@Mike –
它们是垂直的......您只是加/减一小部分实际吞吐量值。尝试乘以你的'数据$错误'100. –
它的工作原理,你能解释为什么我们应该多100错误? @Mike H –