Reputation: 7282
I want to make a plot like this given only the percentiles in my data.frame. So a row in my data.frame would be something like that:
Name; q0.05; q0.25; q0.45; q0.55; q0.75; q0.95
Italy; 76; 88; 95; 109; 112; 123
And this is what I directly want to translate into the plot. Any help or suggestions appreciated!
Upvotes: 1
Views: 1610
Reputation: 173677
A complete reproducable example (like what maybe you could have provided...):
dat <- data.frame(Name = factor(sample(letters[1:5],1000,replace = TRUE)),
val = runif(1000))
datSum <- ddply(dat,.(Name),summarise,q05 = quantile(val,0.05),
q25 = quantile(val,0.25),
q45 = quantile(val,0.45),
q55 = quantile(val,0.55),
q75 = quantile(val,0.75),
q95 = quantile(val,0.95))
datSum$NameAlt <- 1:5
And the plot:
ggplot(datSum,aes(ymin = NameAlt - 0.2,ymax = NameAlt + 0.2)) +
geom_rect(aes(xmin = q05,xmax = q95),fill = "white",colour = "black") +
geom_rect(aes(xmin = q25,xmax = q75),fill = 'lightblue',colour = "black") +
geom_rect(aes(xmin = q45,xmax = q55),fill = 'blue',colour = "black") +
scale_y_continuous(breaks = 1:5,labels = datSum$Name)
Upvotes: 11