ggplot x axis dates out of order

Hi,

Three things:

  1. A reproducible example, called a reprex is helpful to show changes needed. The data contents in the example are invisible.
  2. From help(geom_boxplot()
library(ggplot2)
# You can also use boxplots with continuous x, as long as you supply
# a grouping variable. cut_width is particularly useful
ggplot(diamonds, aes(carat, price)) +
  geom_boxplot()
#> Warning: Continuous x aesthetic -- did you forget aes(group=...)?

ggplot(diamonds, aes(carat, price)) +
  geom_boxplot(aes(group = cut_width(carat, 0.25)))

Created on 2020-01-14 by the reprex package (v0.3.0)

  1. If Month is character, rather than a datetime object, the default is alphabetic. To change the order, convert to factors and reset the order with a vector of month name with factor(Months, levels = my_levels)

Come back with a reprex if you have trouble.

2 Likes