I searched and didn't find my solution yet. I'd like to have multiple lines to joint all boxplot's medians. I saw a lot of example, but it only worked for one set of data (for example: https://digibio.blogspot.com/2016/09/box-plots-and-connect-by-median.html). I want the graph looks as the image below, but if I use this command "stat_summary(fun.y=median, geom="line", aes(group=1)". It only plots one line. I don't know how to plot for multiple lines. Thank you.
Asked
Active
Viewed 392 times
1
-
You probably want `aes(group = type)` not `aes(group = 1)` but it's difficult to know without seeing some example data. – neilfws Mar 05 '18 at 21:54
-
When asking for help, you should 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 Mar 05 '18 at 21:55
-
@neilfws, Thanks neilfws, it plotted multiple lines when I used aes(group = type). However, all the lines had the same black color. I tried to use "stat_summary(fun.y=median, geom="line", aes(group=type), color=type)", I got an error "object 'type' not found". It is really strange, because "type" is used to plot the lines. – Peter Rowan Mar 05 '18 at 22:12
-
@PeterRowan you need to put color inside `aes()` too; `aes(group = type, color = type)`. – neilfws Mar 05 '18 at 22:13
-
@neilfws, Thank you. It works as expected. – Peter Rowan Mar 05 '18 at 22:19