0

I am still learning ggplot, and I'm getting hung up on geom_boxplot. I'm graphing x vs y (both are continuous), and I would like to group it based on a 3rd column (let's call it "z"). However, when I try to graph it as such, I get an unexpected result:

ggplot()+
geom_boxplot(data=df,aes(x=x,y=y,group=z))

The graph looks like this:

enter image description here

This seems to group all datapoints, regardless of their X value, into a single box for the group Z. However, I'd like to create boxplots for each X value in each group in Z.

How would I go about doing this?

Richard Telford
  • 9,558
  • 6
  • 38
  • 51
Andrew
  • 85
  • 2
  • 6
  • 3
    welcome to SO. It doesn't make much sense to plot boxplots of continuous variables, if you don't provide bins to cut them. (That said, boxplots show the distribution of values of categorical data. If you have continuous data, you need to categorise it first) – tjebo Feb 14 '20 at 17:43
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 14 '20 at 18:25

0 Answers0