0

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()
dc37
  • 15,840
  • 4
  • 15
  • 32

1 Answers1

1

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)

dc37
  • 15,840
  • 4
  • 15
  • 32