Modified polar graph using ggplots or other alternative packages using R

I am trying to create a nice (!) Polar graph 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 poses.

in my real data to build more than two levels.

Markers can be either segments or other marks, such as filled colors.

Different groups can optionally encode color.

enter image description here

Alternative with circle segment marking (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()

Other tests:

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

Editing 1:

I think it would be terrible for me to explain this problem. Here is an explanation figure. enter image description here

() , , . . , (, ).

2:

. , .

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

ylim (2,3), , .

Error in data$y[data$y == -Inf] <- range$y.range[1] : 
  replacement has length zero
+3
1

, (- , , , ). :

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

pos , melt() reshape2.

, , ?

cx <- ggplot(df2, aes(y = group, x = cpos))

cx + geom_point(aes(color = factor(group))) + coord_polar() + ylim(0,3)

, ? , x y .

enter image description here

Edit2

, , , , , . , . . , , . .

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

+5

All Articles