I am trying to display a limited number of observations in the text of the x axis, but maintaining the entire population of discrete observations in the plot:
zed <- structure(list(FTD = c(93L, 50L, 88L), FTD_DATE = structure(c(12L, 15L, 2L), .Label = c("01/03/2018", "03/06/2017", "05/05/2017", "08/01/2018", "08/12/2017", "09/07/2017", "11/10/2017", "13/02/2018", "14/09/2017", "15/11/2017", "16/05/2017", "17/11/2017", "18/09/2017", "18/12/2017", "21/07/2017", "21/10/2017", "23/06/2017", "26/05/2017"), class = "factor")), .Names = c("FTD", "FTD_DATE"), row.names = c(NA, 3L), class = "data.frame")
library(ggplot2)
ggplot(data=zed, aes(x=FTD_DATE,y=FTD)) +
theme(axis.text.x = element_text
(angle = 90, vjust = 0.5, hjust = 1.0)) +
geom_point(aes(x=FTD_DATE,y=FTD)) +
scale_x_discrete (breaks=c("05/05/2017","03/06/2017","09/07/2017",
"11/10/2017","08/12/2017","08/01/2018",
"01/03/2018"))
The above gives me a concentration of text in the left of the x axis (7 dates as per breaks argument in the scale_x_discrete, out of 19 dates in total) but leaving a wide blank space in the remaining portion of the axis... Is there a way to spread evenly the text across the entire x axis, choosing the number of observation I want to display in the text, maintaining the entire number of observation in the plot and ordering the dates in the x axis text in ascending order? Bearing in mind that scale_x_date returns error "Error: Invalid input: date_trans works with objects of class Date only".. Thanks