KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to create a circular plot and am stuck at a point: dat1 <- data.frame (xvar = 1:10, y = 6, ymin = 4, ymax = 4.5) Using this data, I can produce a circular ribbon plot in ggplot2 require(ggplot2) ggplot(dat1, aes(x=xvar, y=y)) + geom_ribbon(aes(ymin=ymin, ymax=ymax), col = "blue", fill = "blue2") + ylim (c(0,6)) + coord_polar() However I want more. I want to fill the segment of the ribbon with different colors and labels using the following data. filld <- data.frame (start = c(1, 4, 6, 7.5, 8, 9), end = c(4, 6, 7.5, 8, 9, 10), label = c("A", "B", "C", "A", "C", "D")) filld ## start end label ## 1 1.0 4.0 A ## 2 4.0 6.0 B ## 3 6.0 7.5 C ## 4 7.5 8.0 A ## 5 8.0 9.0 C ## 6 9.0 10.0 D The ribbon will be filled with different color by label variable. For example, the segment A will start from 1 and end at 4. Then segment B will start and end at 6 and filled with different color. Segments with same label (such as A and C) will be connected by line. The resulting plot will look like this:
Tags (comma-separated)
Save Edits
Cancel