r - ggplot - connecting points in polar coordinates with a straight line -


i working on similar issue, discussed here: r - ggplot2: connecting points in polar coordinates straight line

unfortunately, workaround not working anymore.

i made example code talk issue in particular. here tried last: used geom_segment instead of geom_path , ended lines going in circle. these lines head towards 0 first , turn according giving position, instead of taking straight way.

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

enter image description here

is geom_path still better option? tried things geom_path, didn't towards wanted.

i solved issue myself , wanted share findings:

my problem in line:

geom_segment(data=polar, aes(x=0, y=0, xend=winkel2, yend=value, fill=na), 

the starting point x determines direction, in arrow should head in first place. e.g. if set 0, arrows head towards 0 mark , turn towards intended postion making curves. solve issue, had set x=winkel2, each arrow starts @ individual mark , goes straight final position:


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -