The following example shows how to plot XY error bar plot in R using ggplot2
# data
set.seed(8978)
df1 <- data.frame( x1 = 1:50, y = seq(1, 150, 3) + rnorm(50, 0,5) , se = rnorm(50, 0,3))
limits <- aes(ymax = y + se, ymin=y - se)
# data
set.seed(8978)
df1 <- data.frame( x1 = 1:50, y = seq(1, 150, 3) + rnorm(50, 0,5) , se = rnorm(50, 0,3))
limits <- aes(ymax = y + se, ymin=y - se)
#plot
require(ggplot2)
plot1 <- ggplot(df1, aes(y= y, x=x1))
plot1 + geom_point(colour =" red" ) + geom_errorbar(limits, width=1) + theme_bw()
#Adding line to above plot
plot1 + geom_point(colour ="red" ) + geom_line(colour =" blue" ) + geom_errorbar(limits,width=1) + theme_bw()
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.