I'd like to create a bar plot on an Archimedean spiral, like discussed here.
With an end goal of something like this, but less overwhelming.
Here's a sample dataframe:
test <- structure(list(month = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
year = c(2015, 2015, 2015, 2015, 2015, 2015, 2015,
2015, 2015, 2015, 2015, 2015, 2016, 2016,
2016, 2016, 2016, 2016, 2016, 2016, 2016,
2016, 2016, 2016),
value = c(49, 34, 35, 34, 50, 35, 48, 50, 44, 38, 42,
43, 33,30, 42, 43, 58, 55, 47, 36, 35, 53,
61, 59)),
.Names = c("month", "year", "value"),
class = "data.frame", row.names = c(NA, -24L))
I can make a bar graph, using the following code:
ggplot(monthly, aes(x = ym, y = value)) +
geom_bar(stat = "identity")
And I can make the spiral, using the following code:
a <- 0 #Any number here & it still looks the same to me...
b <- 10 #Any number here & it still looks the same to me...
theta <- seq(0,10*pi, 0.01)
r <- a + b*theta
df <- data.frame(x = r*cos(theta), y = r*sin(theta))
ggplot(df, aes(x,y)) +
geom_point(col = 'red')
But how (if at all) can I plot the bars on the spiral?
This is about as close as I've gotten: creating a spiral with my data rather than the above formula. But my data isn't actually displayed...
d <- ggplot(monthly, aes(x = month, y = month, color = year)) +
geom_path(size = 2) +
coord_polar() +
theme_minimal() +
theme(legend.position = "none")
d