Reputation: 1
My data frame consists of one column which as dates in format y/m/d. the other has deaths. The format of the date is posixct. When I plot in R using ggplot the x axis shows days as 1st feb, 15th Feb.. and so on. I want the xaxis with every day as in the data. What do i do? Thank you
baseplot=ggplot(Data_set,aes(x=Date,y=Cumulative_confirmed_cases,colour="red"))+geom_line(size=1)
baseplot+ scale_x_datetime(date_labels = "%b/%d",limits = c(min,max))+geom_point()
Upvotes: 0
Views: 51
Reputation: 16178
You need to add the date_breaks
argument in your scale_x_datetime
in order to get all days displayed:
library(ggplot2)
ggplot(Data_set,aes(x=Date,y=Cumulative_confirmed_cases,colour="red"))+
geom_line(size=1) +
scale_x_datetime(date_labels = "%b/%d",limits = c(min,max), date_breaks = "day")+
geom_point()
If this is not working, please provide a reproducible example of your dataset (see: How to make a great R reproducible example)
Upvotes: 1