我正在使用polar_coord在ggplot中构建一个同心圆图表,我需要去掉一条特定的线。下面是代码和图:
df <- data.frame(A=letters[1:12],
B=c(rep("Dim_1",4),rep("Dim_2",4),rep("Dim_3",4)),
C=c(rep("Ind_1",2),rep("Ind_2",2),rep("Ind_3",2),rep("Ind_2",2),rep("Ind_5",2),rep("Ind_6",2)))
ggplot(df,aes(factor(1),fill=C))+
geom_bar(width = 1,colour="black")+
coord_polar()+
scale_fill_manual(values = c("#FFFFFF","#CCCCCC","#CCCCCC","#999999","#999999"))

我如何去掉从圆心到圆顶的那条线?由于这个极图是由条形图(geom_bar)构成的,另一种提出问题的方式是,如何消除每个条形图底部的边框,而不是边框或顶部的边框?
发布于 2018-09-01 10:30:23
看看下面的方法对你是否有效?注释代码中的解释:
ggplot(df, aes(factor(1), fill = C)) +
geom_bar(width = 1, colour = NA) + # hide all outlines in geom_bar
stat_count(aes(yintercept = cumsum(rev(..count..))), # add only the top line for each
geom = "hline") + # bar in the stack
coord_polar() +
# optional: add black outline to the fill legend
scale_fill_manual(values = c("#FFFFFF","#CCCCCC","#CCCCCC","#999999","#999999"),
guide = guide_legend(override.aes = list(color = "black")))

https://stackoverflow.com/questions/52123169
复制相似问题