在R

时间:2017-06-21 09:43:28

标签: r ggplot2

我创建了以下情节,它给出了我想要的情节的形状。但是,当我将其包裹起来时,形状不再保持三角形,几乎变成细胞。如何在刻面后保持三角形?

示例数据:

lvls <- c("a","b","c","d","e","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15")
df <- data.frame(Product = factor(rep(lvls, 3)), 
             variable = c(rep("Ingredients", 20),
                          rep("Defence", 20),
                          rep("Benefit", 20)),
             value = rnorm(60, mean = 5))

现在当我使用这段代码时,我得到了我想要的形状。

ggplot(df,
   aes(x = variable,
       y = value,
       color = Product,
       group = Product)) +
geom_polygon(fill = NA) + 
coord_polar() 

enter image description here

然而,这些产品都是彼此重叠的,所以理想情况下我想要包装。

ggplot(df,
   aes(x = variable,
       y = value,
       color = Product,
       group = Product)) +
geom_polygon(fill = NA) + 
coord_polar() +
facet_wrap(~Product)

enter image description here

但是当我面对包裹时,形状变得奇怪的细胞而不是三角形(从点到点的直线)。关于如何改变这个输出的任何想法?

感谢。

0 个答案:

没有答案