Pink chart for migration data

I am trying to create a rose diagram showing the average path angle and distance for each subset of cells. I want the angle around the rose diagram to be the angle of the path, and the stroke length on the diagram to be a complete offset.

Here is a set of test data for the average angle and offset per group.

testsum<-data.frame(Group=c(1,2,3),
                angle=c(0.78,1.04,2.094),
                displacement=c(1.5,2,1))

When I try to build this in a circular method, my chart looks very wrong.

p1<-ggplot(testsum, aes(x=angle,y=displacement))+
  coord_polar(theta="x",start=0)+
  geom_bar(stat="identity",aes(color=Group,fill=Group),width=.01)+    
  scale_x_continuous(breaks=seq(0,360,60))

He gives me this chart for output.

enter image description here

Depending on what the data says, it should look bigger (a picture of the intended output). enter image description here

Corners seem to be placed incorrectly? Any idea what I'm doing wrong?

+6
source share
3 answers

Perhaps you can try the following:

testsum$angle_b=180*testsum$angle/pi
#
ggplot(testsum, aes(x=angle_b,y=displacement))+
    geom_bar(stat="identity",aes(color=Group,fill=Group),width=1) +    
    scale_x_continuous(breaks=seq(0,360,10), limits=c(0,360)) + coord_polar(direction=1)
+1

MLavoie " " 20 , , , NISTunits:

library(ggplot2)
library(NISTunits)

testsum <- data.frame(
  Group = c(1, 2, 3),
  angle = c(0.78, 1.04, 2.094),
  displacement = c(1.5, 2, 1)
)

testsum$angle = NISTradianTOdeg(testsum$angle)

ggplot(testsum, aes(x = angle, y = displacement)) +
  coord_polar(theta = "x", start = NISTdegTOradian(-90), direction = 1) +
  geom_bar(stat = "identity",
           aes(color = Group, fill = Group),
           width = 1) +
  scale_x_continuous(breaks = seq(0, 360, 10), limits = c(0, 360))

:

enter image description here

.

+2

Perhaps you can use the windRose function from the open air package

library(openair)
    testsum<-data.frame(Group=c(1,2,3),angle=c(0.78,1.04,2.094),displacement=c(1.5,2,1))
    testsum$angle=180*testsum$angle/pi
windRose(testsum,ws="displacement",wd="angle",breaks=c(0.5,1,1.5,2),paddle=F,key.header = "My Rose",angle=10, 
     statistic="prop.mean",key.footer = "Displacement")

enter image description here

+1
source

All Articles