Johannes
Johannes

Reputation: 705

Plot confidence interval, points and line

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:

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

Upvotes: 1

Views: 8235

Answers (1)

pogibas
pogibas

Reputation: 28379

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

Upvotes: 7

Related Questions