e61-Institute / theme61

Create graphs in the e61 Institute style
https://e61-institute.github.io/theme61/
MIT License
5 stars 0 forks source link

Facet ordering reset by `plot_label()` #217

Open aaronw22 opened 2 months ago

aaronw22 commented 2 months ago

Describe the bug Ordered factor is ignored when the facets are arranged when plot_label() is used to add plot labels.

Code to reproduce

library(ggplot2)
library(theme61)

df <- data.frame(grp = 1:3, val = rep(1, 3))
df$grp <- ordered(df$grp, 3:1)

# this works
ggplot(df, aes(x = val, y = val)) +
  geom_point() +
  facet_wrap(~grp)

# this resets the order
ggplot(df, aes(x = val, y = val)) +
  geom_point() +
  facet_wrap(~grp) +
  plot_label("a point", 1.25, 1, facet_name = "grp", facet_value = "1") +
  scale_x_continuous_e61(c(1, 2))

Expected behavior Facet order follows the ordered factor that is the input vector.