ggplot2:如何向极坐标图添加闭合(和填充)箭头

ggplot2: How to add closed (and filled) arrowheads to a polar plot

关注此link:

ggplot2 polar plot arrows

我一直想知道如何在 ggplot2 的极坐标图上得到闭合箭头。

这是我的代码:

# make some data     
    polar <- structure(list(degree = c(120L, 30L, -120L, 60L, 150L, -90L, 
    -60L, 0L), value = c(0.5, 0.2, 0.2, 0.5, 0.4, 0.14, 0.5, 0.6)), .Names = c("degree", 
    "value"), class = "data.frame", row.names = c(NA, -8L))

    require(ggplot2)
    require(grid)

    base <- ggplot(polar, aes(x=degree, y=value, axis.x = NULL, axis.y = NULL))
    p <- base 
    p <- p + geom_segment(aes(y=0, xend=degree, yend=value)) # add the lines


    awid <- 1
    p <- p + geom_segment(aes(y=0, xend=degree, yend=value)) + geom_segment(aes(y=value-0.05,yend=value,x=degree-awid/value,xend=degree)) +  geom_segment(aes(y=value-0.05,yend=value,x=degree+awid/value,xend=degree))
    p

但是,我得到的箭头是开放的箭头,而不是闭合的。我想知道如何用(基本上)填充的三角形替换箭头并且仍然在极坐标中。有什么建议么?

提前致谢!

PS;更新以添加箭头问题。这是我的代码 运行:

 require(ggplot2)
 require(grid)

 # Data     
 polar <- structure(list(degree = c(120L, 30L, -120L, 60L, 150L, -90L, -60L, 0L), 
                         value = c(0.5, 0.2, 0.2, 0.5, 0.4, 0.14, 0.5, 0.6)), 
                    .Names = c("degree", "value"), 
                    class = "data.frame", row.names = c(NA, -8L))

 ggplot(polar, aes(x=degree, y=value)) +
   geom_segment(aes(y=0, xend=degree, yend=value), arrow=arrow(type="closed")) +
   coord_polar()

这是我得到的情节:

使用 grid 中的 arrow() 函数,您只需调用一次 geom_segment

 require(ggplot2)
 require(grid)

 # Data     
 polar <- structure(list(degree = c(120L, 30L, -120L, 60L, 150L, -90L, -60L, 0L), 
                         value = c(0.5, 0.2, 0.2, 0.5, 0.4, 0.14, 0.5, 0.6)), 
                    .Names = c("degree", "value"), 
                    class = "data.frame", row.names = c(NA, -8L))

 ggplot(polar, aes(x=degree, y=value)) +
   geom_segment(aes(y=0, xend=degree, yend=value), arrow=arrow(type="closed")) +
   coord_polar()