0

Do you know how I can move the Y-axis so it starts at the center of the graph at 90 degree angle?

Here is the plot that I have so far:

plot

Here is the code:

library(dplyr)
library(lubridate)
library(ggplot2)

df <- structure(list(learning_unit = c("4.1", "2.1", "0.1", "0.1", 
                                       "0.1", "0.1", "0.1", "0.1", "0.1", "0.1"), 
                     DateTime = structure(c(1679581080, 
                                            1679573820, 1680278280, 1680265200, 
                                            1680262920, 1680262620, 1680233460, 
                                            1680230820, 1680218220, 1680217560), 
                                          tzone = "UTC", 
                                          class = c("POSIXct", "POSIXt"))), 
                row.names = c(NA, -10L), 
                class = c("tbl_df", "tbl", "data.frame"))

df %>%
  ggplot(aes(x = hour(DateTime),
             group = learning_unit,
             fill = factor(learning_unit))) +
  geom_bar(width=0.95,
           stat="count", 
           colour = "black") +
  coord_polar(start = 0) +
  labs(y = "") +
  theme_minimal()+
  scale_x_continuous("Hour", limits = c(0, 24),
                     breaks = seq(0, 24),
                     labels = c(paste(seq(0, 24),"h")),
                     minor_breaks = NULL) +
  labs(fill='Learning Unit')
Z.Lin
  • 28,055
  • 6
  • 54
  • 94
  • 1
    Hi @Carmen Santana, please take a look at the answer in [this question](https://stackoverflow.com/questions/74264354/how-to-add-y-axis-labels-inside-coord-polar-graph-ggplot). There, the axis labels are being added as an annotation layer. – Seth Mar 31 '23 at 19:57

0 Answers0