这是我的情节:
gr1 <- c(1, 5, 15, 20, 30, 40)
gr3 <- c(1, 5, 10, 25, 40, 60, 80)
gr2 <- c(1, 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)
df2$y <- rep(3, length (df2$cpos))
df2$y1 <- rep(0.35, length (df2$cpos))
df3 <- data.frame (cpos = rep(df2$cpos, 2),
group = rep(df2$group,2), yd = c(df2$y, df2$y1),
x2 = c(rep(1, length (df2$y)),
rep(2, length (df2$y1))))
cx <- ggplot(df3, aes(y = yd, x = cpos, fill=factor(x2)))
cx1 <- cx + geom_area(aes(stat = "identity", position="fill" ))
cx1 + geom_point(aes(color = factor(group)), pch = 19, size = 4) +
scale_fill_manual(values=c("blue", "yellow", "green")) + coord_polar()
我无法摆脱一些问题
(1) 我不能改变点的颜色,颜色改变只适用于圆圈。
(2) 在中心圆绘制附加点,我不想绘制。(它们是额外的 csum 点)
声明:本帖与上一帖相关
额外的意外艺术
在努力解决问题时,我做了一个向日葵情节。
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)
df2$y <- rep(3, length (df2$cpos))
df2$y1 <- rep(0.01, length (df2$cpos))
df2$y3 <- rep(2, length (df2$cpos))
df3 <- data.frame (cpos = rep(df2$cpos, 3), group = c(rep(1, length (df2$y)),
rep(2, length (df2$y)), rep(3, length (df2$y))),
yd = c(df2$y, df2$y1, df2$y3), x3 = c(rep(1, length (df2$y)),
rep(2, length (df2$y1)),rep(2, length (df2$y1)) ))
做花
cx <- ggplot(df3, aes(y = yd, x = cpos, fill=factor(x3)))
cx1 <- cx + geom_area(aes(stat = "identity", position="fill" ))
cx2 <- cx1 + geom_point(aes(color = factor(group)), pch = 19, size = 4) +
scale_fill_manual(values=c("yellow", "pink")) + coord_polar()
cx2 + theme_bw()+ opts(axis.line=theme_blank(),axis.text.y=theme_blank(),
axis.ticks = theme_blank(), axis.title.y=theme_blank(),
plot.background=theme_blank(), panel.border=theme_blank())