When using facet_grid(x ~ y)
with ggplot2 I\'ve seen in various examples and read in the documentation that the x
variable is laid out vertically and t
Change aes(foo$b)
to aes(x = b)
to make sure the aesthetics are mapping correctly.
You want to make sure ggplot
is finding the column labelled b
from the correct scope i.e. from the data that it has been passed. For example, it may be the case that ggplot
rearranged your data when you passed it, so mapping the variable foo$b
no longer aligns with what you want.
I'm not saying this is what happened - just an example of why calling the aesthetic from the correct scope is important.