0
votes

I know there's a lot of question about this topic, but i can't find the answer i need. Years ago i used R, now i can't remember anything, but i'm sure is possible to draw a chart like this, with confidence intervals for every single points, and the main line between points (like in the screenshot). I already have all datas i need, pre calculated with spreadsheet. A simple example:

  • points value (average of previous values): 4 (at 10 meters),5 (at 20 meters),6 (at 30 meters)
  • confidence interval: 0.2 (for value 4), 0.5 (for value 5), 0.9 (for value 6)

I need the syntax to draw a chart like this:enter image description here

1

1 Answers

6
votes

Use ggplot2 for easy and quick plotting.

data <- data.frame(distance = c(10, 20, 30),
                   value    = c(4, 5, 6),
                   CI       = c(0.2, 0.5, 0.9))
library(ggplot2)
ggplot(data, aes(distance, value)) +
    geom_point() +
    geom_line() +
    geom_errorbar(aes(ymin = value - CI, ymax = value + CI)) +
    labs(x = "DISTANCE",
         y = "VALUES",
         title = "MY TITLE") +
    theme_classic() 

enter image description here