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 –