Use geom_ribbon
:
ggplot(data, aes(x=Value, y=mean)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.1) +
geom_ribbon(aes(ymin=mean-se, ymax=mean+se),alpha=0.5) +
geom_line() +
geom_point()
Вопрос
So I used the following code to generate a scatter plot with a standard error
data <- ddply(dat, .(Value), summarise,
N = length(means),
mean = mean(means),
sd = sd(means),
se = sd(means) / sqrt(length(means)) )
ggplot(data, aes(x=Value, y=mean)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.1) +
geom_line() +
geom_point()
Here is sample data
Value N mean sd se
1 11 1.624771 0.1788739 0.05393250
2 6 1.775057 0.2625611 0.10719012
3 11 2.218854 0.4320835 0.13027807
4 10 1.745128 0.3922374 0.12403637
5 9 2.266107 0.1645616 0.05485388
So what I want to try to do is find the 'area' that the standard errors occupy and give a graph that has the standard error areas occupied. Is this possible ? So I just basically want the area occupied by the max standard error and a min standard error for each data point
Решение
Use geom_ribbon
:
ggplot(data, aes(x=Value, y=mean)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.1) +
geom_ribbon(aes(ymin=mean-se, ymax=mean+se),alpha=0.5) +
geom_line() +
geom_point()