I want to create a polar histogram like this
with dashed lines going from the y-axis ticks to the 0/360 line to help the reader to map the count to the histogram's bar length. I have added the dashed lines with power point but I am wondering whether it is possible to add this with ggplot.
I used this code
library(ggplot2)
# Seed
set.seed(20220315)
# Create random data from 0 to 360
example_dat <- data.frame(rot_y = runif(1000, min = 0, max = 360))
# Create polar plot
ggplot(example_dat, aes(x = rot_y )) +
geom_histogram(binwidth = 15, boundary = -7.5, colour = "black", size = .25) +
scale_x_continuous(limits = c(0,360),
breaks = seq(0, 360, by = 60),
minor_breaks = seq(0, 360, by = 15)) +
coord_polar() +
labs(title = 'Polar histogram of y rotation',
y = 'Count',
x = '')
to generate this plot
I am aware of the work around for drawing a line segment like in this solution: draw straight line between any two point when using coord_polar() in ggplot2 (R)
However, when drawing a straight line with function given in that solution using aes(x = 270, y = 0, xend = 720, yend = 60)
, the line just disappears, while a line can be seen for something like aes(x = 270, y = 0, xend = 720, yend = 10)
but the problem is then it does not extent to the label ticks, which make sense as I told the line to end at 10.