Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8282441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:22:15+00:00 2026-06-08T10:22:15+00:00

I am trying to create a circular plot and am stuck at a point:

  • 0

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:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:22:16+00:00Added an answer on June 8, 2026 at 10:22 am

    Here is an example:

    filld$p <- rowMeans(subset(filld, select = c(start, end)))
    ggplot(filld, aes(xmin = start, xmax = end, ymin = 4, ymax = 5, fill = label)) + 
      geom_rect() + 
      geom_segment(data = subset(filld, label %in% label[duplicated(label)]),
                   aes(x = p, y = 0, xend = p, yend = 4, colour = label),
                   size = 2, show_guide = FALSE) +
      geom_text(aes(x = p, y = 4.5, label = label), colour = "white", size = 10) +
      coord_polar() + 
      scale_y_continuous(limits = c(0, 5))
    

    Updated

    I do not recommend but something like this:

    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$p <- rowMeans(subset(filld, select = c(start, end)))
    filld <- merge(filld, ddply(filld, .(label), summarize, p2 = mean(p)))
    
    lnd <- subset(filld, label %in% label[duplicated(label)])
    lnd <- ddply(lnd, .(label), function(x) {
      x <- seq(x$p[1], x$p[2], length = 100)
      y <- 4.5 + ((x - mean(x))^2 - (x[1]-mean(x))^2) / (x[1]-mean(x))^2 * 3 + sin(x*3*pi) * 0.1
      data.frame(x, y)
    })
    
    
    p <- ggplot(filld, aes(xmin = start, xmax = end, ymin = 4, ymax = 5, colour = label, fill = label)) + 
      geom_line(aes(x, y, xmin = NULL, ymin = NULL, xmax = NULL, ymax = NULL), data = lnd, size = 2) +
      geom_rect() + 
      geom_text(aes(x = p, y = 4.5, label = label), colour = "white", size = 10) +
      coord_polar() + 
      scale_y_continuous(limits = c(0, 5))
    p
    

    Perhaps, what you want is beyond the scope of ggplot2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying create a data.frame from which to create a graph. I have
I've been trying create this simple ish to-do list web app using JavaScript &
I'm trying to create a circular menu in CSS for a school project. This
I'm trying to create a UIView that will act as a circular TextView. I'm
Ok so I am trying create a login script, here I am using PHP5
Trying to create a macro which can be used for print debug messages when
Trying to create a background-image slideshow and am getting this error... This is the
I'm trying to create a many-to-many relationship using EF code first in my MVC
I'm trying to create an image for a custom style UIButton using an image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.