I currently have a ggplot that produces dates on the bottom axis, example Jan 1 2020, Jan 2 2020, Jan 3 2020, I am wondering within the code block that produces the ggplot is there an addition I can add to make this in change the format from Jan 1 2020 -> 01-01-2020. I've taken a look at some of the ggplot examples however I can only see this online. is having a YYYY-MM-DD possible on the X-Axis?
I am not sure whether you want the date to be formatted as day-month-year or year-month-day. I opted for day-month-year in the following code. This will work if your dates are actually numeric dates and not character strings.
DF <- data.frame(Date = seq.Date(as.Date("2020-01-01"), as.Date("2020-01-10"), by = 1), Value = 1:10) library(ggplot2) ggplot(DF, aes(Date, Value)) + geom_point()
ggplot(DF, aes(Date, Value)) + geom_point() + scale_x_date(date_labels = "%d-%m-%Y")
Created on 2020-05-25 by the reprex package (v0.3.0)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.