Off topic:ggplot2 category in category
0
0
Entering edit mode
Raymond ▴ 20
@raymond-14020
Last seen 4.9 years ago

Hi, My tmp4 contains the eigengene expression value, age ("young", "middle", "old"), and condition("control", "treatment"), and I want to have a boxplot, with all data point jittered within the box. I tried the following code, but the result is not what I wanted as the jitter plots are not separated within each age group.

scatter_plot <-   ggplot(tmp4, aes_string(x="age", y="eigen", fill="condition")) +
                          geom_boxplot(outlier.shape = NA) +
                          geom_jitter(binaxis='y', stackdir='center',position=position_jitter(0.1),size=3)

Screen-Shot-2019-06-27-at-9-49-10-AM

Any suggestions?

Thanks in advance, Raymond

tmp4

eigen              age       condition
1   0.241501432  Young     Treat
2   0.002142654  Young     Treat
3   0.096973364  Young     Treat
4   0.261369785  Young     Treat
5   0.263761951  Young     Treat
6   0.225908859  Young     Treat
7   0.123418452 Middle     Treat
8   0.109319420 Middle     Treat
9   0.121426945 Middle     Treat
10  0.352128237 Middle     Treat
11 -0.053327288 Middle     Treat
12  0.241667446 Middle     Treat
25 -0.122923889    Old     Treat
26 -0.063950636    Old     Treat
27  0.069677249    Old     Treat
28 -0.198748140    Old     Treat
29 -0.255670807    Old     Treat
30 -0.155559610    Old     Treat
37 -0.139708923  Young      Ctrl
38 -0.290071704  Young      Ctrl
39 -0.216179811  Young      Ctrl
40  0.043609313  Young      Ctrl
41 -0.112979706  Young      Ctrl
42 -0.131247005  Young      Ctrl
43  0.051656000 Middle      Ctrl
44  0.033656072 Middle      Ctrl
45  0.023831766 Middle      Ctrl
46  0.192781337 Middle      Ctrl
47  0.003745609 Middle      Ctrl
48  0.236807363 Middle      Ctrl
61  0.005868482    Old      Ctrl
62 -0.076535498    Old      Ctrl
63 -0.129494823    Old      Ctrl
64 -0.164134180    Old      Ctrl
65 -0.186084177    Old      Ctrl
66  0.115045139    Old      Ctrl
ggplot • 189 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 841 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6