I would like to make a plot with ggplot that looks very close to this (found here):
However, instead of frequency I would like to plot ranges for conditions. Here is a sketch of the plot I want to produce with 5 conditions:
My data is arranged as a start and end coordinate for the range. For example, for condition 5 the start of the range is 30 and the end of the range is 40 (I've labeled this about the graph for clarity). My data is from a file in the form:
id start end
1 20 35
2 60 75
3 10 30
4 80 90
5 30 40
I have about 100 start and end values that I would like to plot in this manner on one graph. The final plot should be only two colors.
UPDATE:
For future reference, Justin's solution produces this:
Something like this:
library(ggplot2)
library(reshape)
dat <- data.frame(lets=letters[1:5], low=1:5, mid=3:7, high=10:14)
dat.melt <- melt(dat, id.vars='lets')
ggplot(dat.melt, aes(x=lets, y=value, fill=variable)) +
geom_bar(stat='identity') +
scale_fill_manual(breaks=c('low','mid','high'), values=c('blue','red','blue')) +
coord_flip()
But fairly dependent on your data...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With