1

I have a problem, I have created something, SD+something, and something-SD, I want connect these points in vertical lines at each point any ideas?

#example code:
 hourvec;
 for (i in 1:length(hourvec)){plotUpper<- sd(hourvec) + hourvec}
 plotUpper;
 for (i in 1:length(hourvec)){plotLower<- hourvec - sd(hourvec)}
 plotLower;
 plot(RIL_table, type= "p", main="Variation in Longevity in DSPR RILs");
 points(plotUpper);
 points(plotLower);
zx8754
  • 52,746
  • 12
  • 114
  • 209
Chad
  • 149
  • 4
  • 11
  • This could help? http://stackoverflow.com/questions/12033319/plot-mean-and-sd-of-dataset-per-x-value-using-ggplot2 – zx8754 Nov 06 '13 at 20:28
  • Hi zx8754 this isnt excatly what I am looking for I am looking to make a plot with fly lines (x), hours (y) I want vertical lines on this plot with the SD+/- of hours. – Chad Nov 06 '13 at 20:48
  • It's not clear to me what you are asking for. Is it something like [?abline](http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/abline.html) or [?arrows](http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/arrows.html)? – gung - Reinstate Monica Nov 06 '13 at 21:05
  • 2
    It would also help if you could add a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) & what you want the output to look like. – gung - Reinstate Monica Nov 06 '13 at 21:11
  • Hi gung I dont have a plot like this, what I have is a dataframe that is has line name and hours, I created two vectors plotUpper and plotLower. when I plot them I have three sets of dots stacked. I want to connect these stacked dots with a vertical line, and repeat this for each set of stacked dots. – Chad Nov 06 '13 at 21:13

1 Answers1

0

I think what you need is a candlestick chart, try this:

#example data
set.seed(1); hourvec <- runif(20)
sd_hourvec <- sd(hourvec)

#get hourvec upper lower
plotUpper <- sd_hourvec + hourvec
plotLower <- hourvec - sd_hourvec

#plot
plot(hourvec, ylim = (c(-2, 2)))
for(x in seq_along(hourvec)) lines(c(x, x), c(plotUpper[ x ], plotLower[ x ]))

enter image description here

zx8754
  • 52,746
  • 12
  • 114
  • 209