有没有一种方法可以根据每个点的条形图将点形图覆盖在条形图上?

时间:2019-10-29 16:11:13

标签: r ggplot2

我正在尝试将与每个条形图关联的点添加到ggplot2图中。我不明白为什么这些点没有像图表那样组织。如何根据条形而不是x轴变量来排列点?

我尝试制作另一个叠加层,但是它没有以所需的方式拆分数据:

Graph of ggplot2

ggplot(rdata, aes(variable, value, fill = Treatment)) + 
  stat_summary(fun.y = mean, geom = "bar", position = position_dodge(width = 0.9)) +
  theme_classic() +
  theme(text = element_text(size = 16, face = "bold")) +
  scale_fill_grey(name = "") +
  ylab("Relative CD11b Expression") +
  xlab("") +
  stat_summary(geom = "errorbar", fun.data = mean_se, position = position_dodge(0.9), size = 0.3, width = 0.3) +
  geom_jitter(position = position_identity())

下面是样本数据值

   Treatment    variable     value
1    HFD+LPS    Amygdala 1.7184535
2    HFD+LPS    Amygdala 1.9904329
3    HFD+LPS    Amygdala 1.6025593
4    HFD+LPS    Amygdala 2.2624420
5    HFD+LPS    Amygdala 2.1697814
6    HFD+LPS    Amygdala 1.3641929
7    CHD+LPS    Amygdala 0.8125338
8    CHD+LPS    Amygdala 1.0721207
9    CHD+LPS    Amygdala 2.7181632
10   CHD+LPS    Amygdala 1.1883906
11   CHD+LPS    Amygdala 1.7618055
12   CHD+LPS    Amygdala 1.4261327
13       HFD    Amygdala 1.3379231
14       HFD    Amygdala 0.8181424
15       HFD    Amygdala 0.7176474
16       HFD    Amygdala 0.8470046
17       HFD    Amygdala 1.2694769
18       HFD    Amygdala 2.0215795
19      CHD     Amygdala 1.9141461
20      CHD     Amygdala 2.1411518
21      CHD     Amygdala 2.1104577
22      CHD     Amygdala 0.9601264
23      CHD     Amygdala 2.3873088
24      CHD     Amygdala 2.5354091
25   HFD+LPS Hippocampus 1.8772147
26   HFD+LPS Hippocampus 0.7938240
27   HFD+LPS Hippocampus 1.9498375
28   HFD+LPS Hippocampus 1.7736435
29   HFD+LPS Hippocampus 3.4728941
30   HFD+LPS Hippocampus 1.3806457
31   CHD+LPS Hippocampus 0.6630722
32   CHD+LPS Hippocampus 0.6639194
33   CHD+LPS Hippocampus 0.7283285
34   CHD+LPS Hippocampus 1.9721344
35   CHD+LPS Hippocampus 3.7725719
36   CHD+LPS Hippocampus 1.3293153
37       HFD Hippocampus 0.5718558
38       HFD Hippocampus 0.5955154
39       HFD Hippocampus 0.4096584
40       HFD Hippocampus 0.8230605
41       HFD Hippocampus 1.1175684
42       HFD Hippocampus 0.8778159
43      CHD  Hippocampus 0.3466085
44      CHD  Hippocampus 0.3950703
45      CHD  Hippocampus 0.5400010
46      CHD  Hippocampus 0.2032497
47      CHD  Hippocampus 0.8487227
48      CHD  Hippocampus 0.9546050

我希望每个点都在与之关联的条形中,例如,如果某个点是针对杏仁核和冠心病的,则该点应仅在与之关联的条形中

0 个答案:

没有答案