I need to fill $\lambda$ = x
(6 values of x) on each of the 6 facet_grid panels
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
facet_grid(am ~ cyl) +
theme(panel.spacing = unit(1, "lines")) +
annotate("text", label = c("\u03BB = 1", "\u03BB = 2", "\u03BB = 0.1", "\u03BB = 2.2", "\u03BB = 1.5", "\u03BB = 5") , size = 4, x = 30, y = 5)
I've modified the solutions here Annotating text on individual facet in ggplot2 but got an error.
Error in `check_aesthetics()`:
! Aesthetics must be either length 1 or the same as the data (36): label
Backtrace:
1. base `<fn>`(x)
2. ggplot2:::print.ggplot(x)
4. ggplot2:::ggplot_build.ggplot(x)
5. ggplot2 by_layer(function(l, d) l$compute_geom_2(d))
6. ggplot2 f(l = layers[[i]], d = data[[i]])
7. l$compute_geom_2(d)
8. ggplot2 f(..., self = self)
9. self$geom$use_defaults(data, self$aes_params, modifiers)
10. ggplot2 f(..., self = self)
11. ggplot2:::check_aesthetics(params[aes_params], nrow(data))
The expected graph should have the values of lambda
follow the =
sign as follow