I'm trying to create a horizontal line chart with 5 categories (qualitative variable). The trick is I have multiple horizontal lines (quantitative variable) in each of the 5 categories and I'm unable to plot it in R.
My sample data has the following attributes:
slno start finish
1 0.45 0.52
1 0.52 0.6
1 0.63 0.69
1 0.77 0.9
1 1.55 1.75
1 10.4 12.5
1 2.09 2.35
1 0.52 0.9
2 0.43 0.45
2 0.45 0.51
2 0.52 0.59
3 0.63 0.67
3 0.85 0.88
3 1.57 1.65
4 2.11 2.29
4 0.5 0.68
4 1.36 1.38
4 10.6 11.19
5 11.5 12.51
5 0.43 0.45
5 0.48 0.52
5 0.54 0.57
The graph should look something like this:
This graph is a very rough representation of what I'm after and is by no means representative of the data I've pasted above.
Here's what I've attempted so far.
ggplot(data) +
geom_segment(aes(x=start, y=slno, xend=finish, yend=5), color="blue")
Is it what you are looking for ?
library(ggplot2)
ggplot(df)+
geom_segment(aes(x = start, xend = finish, y = slno, yend = slno, color = as.factor(slno)), size = 2)