0

For the following dataset I am trying to mark the SD over the ggplot and highlight it.

ID    S1      S2
1   21.09542  71.06014
2   21.09564  71.06064
2   21.09619  71.06128
2   21.09636  71.06242
2   21.09667  71.06564
2   21.09483  71.06619
2   21.09483  71.06619
1   21.09264  71.06633
3   21.08986  71.06678
3   21.08925  71.06653
3   21.08925  71.06653
1   21.08925  71.06653
and so on...

This is my path from the dataset link I tried this command for plotting the SD over the ggplot:

#Data frame with mean and SD
df4 <- Data %>% group_by(ID) %>% mutate(SD1 = sd(s1)) %>% mutate(SD2 = sd(s2)) %>% mutate(mean_s1 = mean(s1)) %>% mutate(mean_s2 = mean(s2))

I have made a path via geom_path(), now I want to highlight the SD over this path. Something like this link, where the highlighted path is showing me the SD from the path.

plt <- ggplot(df4, aes(x = s1, y = s2, colour = ID), pch = 17) +geom_point()
plt + geom_path(data = rbind(cbind(tail(Data.sel, -1), grp = 1:(nrow(Data.sel)-1)),  
        cbind(head(Data.sel, -1), grp = 2:nrow(Data.sel)-1)),
        aes(group = interaction(grp)), arrow= arrow(type = "closed", angle = 12), colour="grey") +
geom_errorbar(aes(x=Latitude, ymin=Longitude-std.latitude, ymax=Longitude+std.longitude))
ayush
  • 343
  • 3
  • 20
  • Please make the example reproducible. Have you compared your code to the [docs](http://docs.ggplot2.org/current/geom_errorbar.html)? – Roman Luštrik Jun 30 '15 at 07:13
  • @docs Reproducible? I have produced the SD markings but i still have the problem in highlighting that path. – ayush Jun 30 '15 at 07:20
  • What I meant is to provide data in a easy to transfer form (like using `dput` or simulate data using the rich toolbox of distributions and sampling functions) and plotting code you used that is giving you problems. See [how to make a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) thread for reasoning and working tips. – Roman Luštrik Jun 30 '15 at 07:22

0 Answers0