Plotting Confidence intervals to multiple lines in ggplot2

北城余情 提交于 2019-12-13 05:23:36

问题


I am fairly new to R and I am working on analyzing some data in ggplot2.

I have one set of data that has hormone values for a type of animal. The animals came from two sites (Control, New). I analyzed the data using an ANCOVA and plotted the predicted regression lines based on the model. What I would really like to do, is plot dotted confidence interval lines around both lines on my graph. I can't seem to find/figure out how to perform this using the ggplot2 package. I moved to the package initially because my sample sizes are unequal. Any help would be appreciated.

Here is the code I have used thus far:

Data <- read.csv("Data.csv")
library(ggplot2) # package for plotting
library(outliers) # package for rntransform
aov.con <- aov(rntransform(Hormone) ~ Length + Status, data=Data) ### ANCOVA 

pred <- predict(aov.con)

ggplot(Data, aes(Length, Hormone, color=Status)) + 
geom_point() + 
geom_line(aes(y=pred)) + 
theme_bw() + 
theme(panel.border = element_rect(colour = "black", fill=NA, size=1),        
panel.grid.major = element_blank(), 
panel.grid.minor = element_blank(), axis.line = element_line(colour =   
"black"))

来源:https://stackoverflow.com/questions/33885313/plotting-confidence-intervals-to-multiple-lines-in-ggplot2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!