ggplot - x axis discrete variables

42 views
Skip to first unread message

Al Grasso

unread,
Mar 4, 2018, 10:33:24 AM3/4/18
to ggplot2
Hi all. 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:

x <-ggplot(data=zed, aes(x=FTD_DATE,y=FTD)) +
  theme(axis.text.x = element_text
        (angle = 90, vjust = 0.5, hjust = 1.0)) +
  #coord_cartesian(xlim=c(0,7)) +
  geom_point(aes(x=FTD_DATE,y=FTD)) +
  scale_x
  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) 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?  Thanks 
Reply all
Reply to author
Forward
0 new messages