Why is facet_grid placing the distributions in the wrong quadrants?

后端 未结 1 586

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

相关标签:
1条回答
  • 2021-01-26 09:37

    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.

    0 讨论(0)
提交回复
热议问题