Right now I have a graph that is displaying the months as numbers 01,02, …
, and I would like to change them into the actual month name. I used this code but get a discrete value error each time.
scale_x_continuous(breaks = c(01,02,03,04,05,06,07,08,09,10,11,12), labels = c("Jan_21", "Feb_21", "Mar_21", "Apr_21", "May_21", "Jun_21", "Jul_21", "Aug_21", "Sep_21","Oct_21","Nov_21","Dec_21"))
So I tried to change it to
scale_x_discrete(breaks = 1:12, labels = c("Jan_21", "Feb_21", "Mar_21", "Apr_21", "May_21", "Jun_21", "Jul_21", "Aug_21", "Sep_21","Oct_21","Nov_21","Dec_21"))
but now only the last three months oct, nov, dec show up on my chart.
full code:
ggplot(aes(x=month, y = number_of_rides, fill = member_casual)) +geom_col(position = "dodge") + labs(x="Month", y = "Total Number of Rides", title = "Table #2: Number of Rides per Month by Rider Type", fill = "Type of Membership") +
scale_y_continuous(breaks = c(0e+00, 1e+05, 2e+05, 3e+05, 4e+05), labels = c("0","100k","200k","300k","400k")) +
scale_x_discrete(breaks = 1:12, labels = c("Jan_21", "Feb_21", "Mar_21", "Apr_21", "May_21", "Jun_21", "Jul_21", "Aug_21", "Sep_21","Oct_21","Nov_21","Dec_21")) +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))
Any pointers?