Dates in ggplot/tidyverse

Good day,

I am a new user and am trying to plot some data and the dates all run together on the x-axis. My data is in a table format.

I am using the following code

ggplot(dmr,aes(x = date, y = bod)) +
geom_point() +
labs(x = "Date",y = "BOD(mg/L)",
theme(axis.text.x=element_text(angle=45,hjust=1)),
title = "City of XXXX")

I can't seem to figure out why the dates won't display at the 45 degree angle?

Many thanks!!
Marty

The theme function should not be inside of the labs() function. At least, I have never seen that and I would expect it to throw an error. I may just be unaware of that method, but try putting theme() after the labs(), connecting them with a + sign.
Also, it looks like your dates are being read as characters, not as numeric dates. There are convenient functions in the lubridate package. If your dates have the format m-d-y, use the mdy() function.

As mentioned by @FJCC this is an overview of the lubridate function:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.