r - Cannot get Plots from ggplot in Rstudio -
i'm new r. have been working on plotting data, working fine, of sudden i'm not getting plot in rstudio. i've reinstalled rstudio. missing in code? thanks
library(ggplot2) library(rmisc) srl<-summaryse(combinedwinrhizosigmaplot, measurevar="slr", groupvars=c("rootstock")) offset.v = -3 offest.h = 0.5 ggplot(srl,aes(x=roostock, y=srl, ymax=70000, ymin = 0)) + geom_bar(stat="idendity",fill="gray50", colour="black", width = 0.7) + geom_errorbar(aes(ymax=srl+se, ymin=srl-se), width = 0.0, size=0.5, color = "black")+ geom_text(aes(label=c("bc","bc","a","cde","g","fg","efg","cd","defg","cdefg","ab","a","cd","cdef","defg","cd","a","cdefg"), hjust=offest.h, vjust=offest.v) + labs(x = "rootstock", y = "specific root length") + theme_bw() + theme(panel.grid.major.x = element_blank(), panel.grid.major.y = element_line(colour = "grey80"), plot.title = element_text(size = rel(1.5), face = "bold", vjust = 1.5), axis.title = element_text(face = "bold"), axis.title.y = element_text(vjust=1.8), axis.title.x = element_text(vjust= -0.5), panel.border = element_rect(colour="black") )
since cannot attach .csv file, here dataset combinedwinrhizosigmaplot, partial since quite large , cannot attach it. geom_text not correct since number of rootstock less in sample dataset in total set. thank you!
rootstock slr 33739.58824 29812.64286 29209 31410.58824 31833.39474 18747.52381 38536.79412 25384.61702 30997.22835 17498.90625 24195.32258 23230.88158 41197.3 49207.17391 49459.625 48379.08333 39909.5 34406.26316 34062.32 41217.35417 37801.85333 32362.85235 29592.44144 41183.56311 b 30143.42857 b 36234.45455 b 20233.33333 b 37056 b 28529.67568 b 34542.05263 b 37576.95238 b 34754.15625 b 20086.33333 b 29096.5 b 25690.225 b 21062.61832 b 38229.04167 b 31150.44 b 42008.95652 b 40174.88571 b 39374.97059 b 34751.96296 b 44326.18333 b 35507.5283 b 36021.58242 b 40078.10744 b 34904.34667 b 34403.11594 c 33633.44444 c 30306 c 44506 c 24916.11111 c 45506.75 c 30893.53333 c 63469.6 c 29932.19231 c 33791.26563 c 21850.45714 c 24615.34328 c 29308.10484 c 50217 c 55341.42857 c 54483.71429 c 51372.22222 c 50002.14286 c 43051.16667 c 49146.46667 c 48473.44231 c 32102.69298 c 35886.97647 c 34507.8 c 45671.38636
this work. @teja picking few typos.
there few other typos in code, careful next time. calculated upper , lower bars prior running plot (seems way go ggplot2 v2). did not include geom_text() expression because of text missing, code should fix problem.
srl$lower <- srl$slr - srl$se srl$upper <- srl$slr + srl$se ggplot(srl,aes(x=rootstock, y=slr)) + geom_bar(stat="identity",fill="gray50", colour="black", width = 0.7) + geom_errorbar(aes(ymax=upper, ymin=lower), size=0.5, color = "black") + labs(x = "rootstock", y = "specific root length") + theme_bw() + theme(panel.grid.major.x = element_blank(), panel.grid.major.y = element_line(colour = "grey80"), plot.title = element_text(size = rel(1.5), face = "bold", vjust = 1.5), axis.title = element_text(face = "bold"), axis.title.y = element_text(vjust=1.8), axis.title.x = element_text(vjust= -0.5), panel.border = element_rect(colour="black") )
Comments
Post a Comment