0

I have a data.frame where wing length has been registered for a bird over multiple years. I want to plot the wing length as the y-axis and day of the year (mm/dd) as the x-axis.

I have added a column in Excel where mm/dd is extracted from the date and I am running the following code:


    ggplot(BLACKBIRD, aes(`Day of year`, VIN, group = `Day of year`)) +
      geom_boxplot(fill="white", color="black", width= 0.8) +
      ggtitle("Blackbirds DOY") +
      xlab("DOY") +
      ylab("Wing length (mm)") +
      theme_bw() +
      theme(axis.title = element_text(size = 9)) +
      stat_summary(fun = mean, color="red", geom = "point") +
      theme(axis.text= element_text(size= 7, angle = 0))

My plot is currently very cluttered along the x-axis since all the dates are shown. I want to sequence it so every 10th day is shown along the x-axis.

I know that I need to add something along the line of "scale_x" but I am not sure which one and how I would sequence it.

Snooty
  • 5
  • 4
  • 1
    You probably have to convert the `Day of year` columns to a `Date` class, then the x-scale will be chosen automatically. If the breaks are still too dense you can set them with `scale_x_date(date_breaks = "10 days")`. – teunbrand Jun 08 '20 at 16:42
  • If I try importing is as date then it just turns to NA so I have to import it as character. I have tried to convert it using as.Date() but it returns me the following error: ``` > BLACKBIRD$`Day of year` <- as.Date(BLACKBIRD$`Day of year`) Error in charToDate(x) : character string is not in a standard unambiguous format``` @teunbrand – Snooty Jun 08 '20 at 16:49

0 Answers0