0

I'm trying to recreate this type of graph with R, possible ggplot but not wedded to it.

enter image description here

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")

But I just end up with a spiral - and I'm not really sure where to go from here. I didn't know if I need to start using the angle and try and build x/y coordinates from that.

James Holland
  • 1,102
  • 10
  • 17
  • See e.g. [ggplot2 polar plot arrows](https://stackoverflow.com/questions/10515703/ggplot2-polar-plot-arrows) and "Linked" therein, for some ideas. – Henrik Dec 13 '18 at 21:25

1 Answers1

0

Based on above feedback in the comments - this is the answer I came up with. Thank you to everyone.

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))

enter image description here

James Holland
  • 1,102
  • 10
  • 17