【发布时间】:2017-02-16 14:30:10
【问题描述】:
我正在研究一个类似的问题,正如这里已经讨论过的: r - ggplot2: connecting points in polar coordinates with a straight line
不幸的是,解决方法不再有效。
我编写了一个示例代码来专门讨论我的问题。这是我最后尝试的:我使用geom_segment 而不是geom_path,最后我得到了一个圆圈。这些线总是先向零,然后根据给定的位置转弯,而不是直行。
require(grid)
require(ggplot2)
set.seed(40);
Location<-data.frame(Winkel=round(runif(1000,0,24),0))
Location$BAD <- Location$Winkel %in% c(seq(7,18))
Abschnitte<-c(0:24)
polar<-data.frame(Winkel2=c(1.5, 2.34, 1.2, 3.45, 1.67, 2.61, 1.11, 13.2),
value=c(0.1, 0.03, 0.02, 0.015, 0.01, 0.04, 0.09, 0.06),
.Names=c("Winkel2", "value"))
ggplot(Location, aes(x = Winkel, fill = BAD, y=(..count..)/sum(..count..))) +
geom_histogram(breaks = seq(0,24), colour = "black") +
coord_polar(start = 0) + theme_minimal() +
scale_fill_brewer(type="seq",palette=3) +
ylab("Percentual allocation time") +
ggtitle("") +
scale_x_continuous("", limits = c(0, 24), breaks = Abschnitte, labels = Abschnitte) +
scale_y_continuous(labels = scales::percent)+
geom_segment(data=polar, aes(x=0, y=0, xend=Winkel2, yend=value, fill=NA),
arrow=arrow(angle=30,type="closed",length=unit(0.3,"cm")))
geom_path 还是更好的选择吗?我用geom_path 尝试了一些东西,但并没有真正到达我想要的地方。
【问题讨论】: