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 7899709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:46:36+00:00 2026-06-03T08:46:36+00:00

I am trying to create nice (!) polar plot with the following data. gr1

  • 0

I am trying to create nice (!) polar plot with the following data.

gr1 <- c(0, 5, 15, 20, 30, 40)
gr3 <- c(0, 5, 10, 25, 40, 60, 80)
gr2 <- c(0, 15, 25, 30, 40)

df2<- data.frame (pos = c(gr1, gr2, gr3), group = c(rep(1, length(gr1)),
 rep(2, length(gr1)), rep(2, length(gr1))))



inner circle segment to mark
                   first tier, group 1, between 15, 20
                               group 3, between 5, 10
                                        between  40 to 60 
                   second tier, group 1, between 15, 20
                               group 3, between 5, 10
                                        between 10, 25
                                        between  40 to 60 

The angle between two lines between the interval between two pos.

there are more than two tier in my real data to plot.

The markers might be either segments or other marks such as filled colors.

Different group can color coded if possible.

enter image description here

Alternative with circle segment markings (preferred)

enter image description here

I tried it with ggplot2.

cx <- ggplot(df2, aes(x = pos, group = group) +   geom_bar(width = 1, colour = "black"))
Error in aes(x = pos, group = group) + geom_bar(width = 1, colour = "black") :
  non-numeric argument to binary operator
cx + coord_polar()

More trials:

df2$cpos <- cumsum (df2$pos)
cx <- ggplot(df2, aes(x = cpos, group = group) +   geom_bar(width = 1, colour = "black"))

Edits 1:

I think I might be terrible to explain the issue. Here is figure with explanation.
enter image description here

The pos (position) is a continuous scale, angle in polar should depend upon where value of position is. It will restart once one group is done. I did a trick to cumsum to this trick (I might be wrong).

Edits 2:

The following answer opened more thoughts into the question. This is improved version but color management is not working.

df2$cpos <- cumsum (df2$pos)
df2$y <- rep(3, length (df2$cpos))
cx <- ggplot(df2, aes(y = y, x = cpos))
cx + geom_bar(aes(stat = "identity",fill="yellow", colour = "yellow" )) + 
geom_point(aes(color = factor(group)), pch = 18, size = 2) + coord_polar() +
 scale_fill_manual(values=c("#CC6666", "#9999CC", "#66CC99"))+ ylim(0,3)

enter image description here

When I try to set ylim (2,3) so that they look like segments that do not work as well.

Error in data$y[data$y == -Inf] <- range$y.range[1] : 
  replacement has length zero
  • 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-03T08:46:37+00:00Added an answer on June 3, 2026 at 8:46 am

    I am having a hard time understanding what you want to do (bar-plot counts frequencies, you probably know that). However here is a way to assign the groups into colors:

    gr1 <- c(0, 5, 15, 20, 30, 40)
    gr3 <- c(0, 5, 10, 25, 40, 60, 80)
    gr2 <- c(0, 15, 25, 30, 40)
    
    df2<- data.frame (pos = c(gr1, gr2, gr3), group = c(rep(1, length(gr1)),
     rep(2, length(gr2)), rep(3, length(gr3))))
    df2$cpos <- cumsum (df2$pos)
    
    cx <- ggplot(df2, aes(fill = factor(group), x = cpos))
    
    cx + geom_bar(width = 1, colour = "black", position = "dodge")  + coord_polar()
    

    enter image description here

    If you want to get pos as frequencies, use the melt() function in reshape2.

    If you want to use dots as in your example, could following approach work?

    cx <- ggplot(df2, aes(y = group, x = cpos))
    
    cx + geom_point(aes(color = factor(group))) + coord_polar() + ylim(0,3)
    

    Anyway, you see the pattern? Make a plot with normal coordinates using x-axis as angle and y-axis as distance from the middle and just convert it to polar coordinates.

    enter image description here

    Answer to Edit2

    I am still wondering whether you could make a plot that makes more sense, but maybe you have a reason to do this. Here is a plot that is closer to your example. It isn’t perfect. Maybe the gurus can give you a better suggestion tomorrow once they arrive their offices. In a mean while you can look for more specifications from the links of this tread.

    library(ggplot2)
    
    gr1 <- c(0, 5, 15, 20, 30, 40)
    gr3 <- c(0, 5, 10, 25, 40, 60, 80)
    gr2 <- c(0, 15, 25, 30, 40)
    
    df2<- data.frame (pos = c(gr1, gr2, gr3), group = c(rep(1, length(gr1)),
     rep(2, length(gr2)), rep(3, length(gr3))), y  = c(rep(1, length(gr1)),
     rep(2, length(gr1)), rep(2, length(gr1))))
    
    df2$cpos <- cumsum (df2$pos)
    
    cx <- ggplot(df2, aes(y = y, x = cpos))
    cx + geom_point(aes(color = factor(group)), size = 4) + geom_line(aes(x = c(0,500), y = c(1)), color = "yellow") + 
    geom_line(aes(x = c(0,500), y = c(2)), color = "blue") + scale_y_continuous(limits=c(0,2), breaks = c(0,1,2)) +
    scale_x_continuous(labels = df2$pos, breaks = df2$cpos, limits = c(0,500)) + coord_polar() +
    opts(panel.grid.major = theme_line(colour = "grey"), 
    panel.grid.minor = theme_line(colour = "grey", linetype = "dashed"), 
    panel.background = theme_rect(colour = "white"))
    

    enter image description here

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

Sidebar

Related Questions

Following this nice example I found, I was trying to create a function that
I am trying to create a nice layout for my list items, but my
I'm trying to create a nice generic way of setting the tab index on
I am trying to create a nice column list in python for use with
Im trying to find out a good JavaScript library that can create a nice
I'm trying to create a GWTP sample app. There is a really nice screencast
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
I'm trying to create some nice links over my website. I'm creating a search
I'm trying to create nice looking report of csv file which contain: ,column_1, column_2,column_3,column_4
I'm currenty trying to create a nice nested navigation menu. The problem I face

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.