[英]R Plot Lines on Polar Plot using another variable for the angle
我正在尝试使用R(可能是ggplot)重新创建这种类型的图形,但并没有对其进行约束。
mydata <- data.frame(Group = letters[1:5],
Distance = seq(1000, 5000, 1000),
Change = c(-10, 5, -20, 15, -30))
# Input the same origin point
mydata <- rbind(mydata, data.frame(Group = letters[1:5], Distance = 0, Change = 0))
ggplot(mydata, aes(x = Change, y = Distance, group = Group)) + geom_line() + coord_polar(theta = "y")
但是,我最终陷入螺旋式增长-我不确定从这里到哪里。 我不知道是否需要开始使用该角度并尝试从中建立x / y坐标。
根据评论中的上述反馈-这是我想出的答案。 谢谢大家
library(ggplot2)
mydata <- data.frame(Group = letters[1:5],
Distance = seq(1000, 5000, 1000),
Change = c(-10, 5, -20, 15, -30))
# Input the same origin point
mydata <- rbind(mydata, data.frame(Group = letters[1:5], Distance = 0, Change = 0))
ggplot(mydata, aes(x = Change, y = Distance, color = Group)) + coord_polar(start = 3.5*pi*max(mydata$Change)/diff(range(mydata$Change))) +
geom_segment(aes(y = 0, xend = Change, yend = Distance))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.