r - changing colour or thickness of one point of data set in ggplot2 -
i currrently plotting effects of data set.
i added column (bp) dataset , able colorise graph boat phase.
boatphs fit se lower upper bp 1 before 3.685875 0.3287521 3.038621 4.333130 before 2 after0-20nta 3.317189 0.6254079 2.085872 4.548506 after0-20 3 after0-20taa 5.579384 0.5696270 4.457890 6.700878 after0-20 4 after0-20tap 3.932360 0.4304098 3.084960 4.779760 after0-20 5 after20-40nta 4.522714 0.7771793 2.992586 6.052842 after20-40 6 after20-40taa 4.505207 0.5500699 3.422217 5.588196 after20-40 7 after20-40tap 3.602183 0.3880538 2.838174 4.366192 after20-40 8 approachnta 4.039599 0.5688482 2.919638 5.159560 approach 9 approachtaa 4.421112 0.5176408 3.401969 5.440255 approach 10 approachtap 4.497809 0.3978328 3.714547 5.281071 approach # speed plot spdplot <- ggplot(y, aes(x=boatphs, y=fit, colour=bp, ymax=max(fit)*1.05)) + geom_point(position = position_dodge(width = 0.5, height = 0), size = 2) + geom_errorbar(aes(ymin=fit-se, ymax=fit+se), position = position_dodge(width = 0.5, height = 0), width = 0.5) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))+ #run spdplot spdplot #sets x values in results order + relables x + y axes + changes colours spdplot + scale_x_discrete(limits=c("before","approachnta","approachtaa","approachtap","after0-20nta","after0-20taa","after0-20tap", "after20-40nta","after20-40taa","after20-40tap")) + xlab("boat phase") + ylab("log of group travel speed") + annotate("text", x=6, y=6.2, label="***") + annotate("text", x=4, y=4.95, label="*") + theme(axis.title.x = element_text(vjust=-0.5), axis.title.y = element_text(vjust= 1), axis.text.x = element_text(size=12), axis.text.y = element_text(size=12)) + theme(legend.title = element_blank()) + scale_colour_manual(values=c("#999999","#666666","#cccccc","#000000"), breaks=c("before", "approach", "after0-20", "after20-40"), labels=c("before", "approach", "after0-20", "after20-40"))
what able make point , error bars on before phase thicker , bolder. know how alter details of single point? or multiple different points? know how change them multiple groups make 1 point stand out little bit more others.
cheers
if first add variable y , make before phase t, can conditionally thicken, bold , color it. code below shows color only.
y$bold <- c(t, rep(f, 9))
here plot done red color:
spdplot <- ggplot(y, aes(x=boatphs, y=fit, colour=bp, ymax=max(fit)*1.05)) + geom_point(position = position_dodge(width = 0.5, height = 0), size = 2) + geom_errorbar(aes(ymin=fit-se, ymax=fit+se, color = ifelse(y$bold == t, "green", "black")), position = position_dodge(width = 0.5, height = 0), width = 0.5) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))
Comments
Post a Comment