geom_point dodge spreading unevenly

I am trying to plot antibody levels, GMT (Y axis) at four different time points (X axis) for a group of 55 individuals using geom_point, linking each person's data with geom_lines so I can see the trends over time (I don't have data for all time points and all individuals) In order to make indivuals' lines easier to follow, I want to dodge the points in the X axis. I have used position_dodge2 to do so and I manage to get the points and lines to match, but the dodging is uneven and not centered along the X axis.

Is there a way to make the dodging even and centered along the X axis?

Thank you in advance

This is where I am so far enter image description here

This is my dataset:

NadA
   ID    Time       GMT
    <fct> <chr>    <dbl>
  1 1     Baseline     2
  2 2     Baseline     2
  3 3     Baseline     8
  4 4     Baseline     2
  5 5     Baseline     2
  6 6     Baseline     2
  7 7     Baseline   256
  8 8     Baseline     1
  9 9     Baseline     1
 10 10    Baseline     1
 11 11    Baseline     2
 12 12    Baseline     8
 13 13    Baseline    32
 14 14    Baseline     8
 15 15    Baseline     1
 16 16    Baseline   256
 17 17    Baseline    32
 18 18    Baseline     1
 19 19    Baseline   128
 20 20    Baseline    32
 21 21    Baseline     1
 22 22    Baseline     4
 23 23    Baseline     1
 24 24    Baseline   256
 25 25    Baseline     1
 26 26    Baseline     1
 27 27    Baseline   128
 28 28    Baseline     1
 29 29    Baseline     1
 30 30    Baseline     1
 31 31    Baseline    16
 32 32    Baseline   256
 33 33    Baseline     1
 34 34    Baseline     1
 35 35    Baseline     8
 36 36    Baseline     1
 37 37    Baseline   256
 38 38    Baseline    64
 39 39    Baseline   128
 40 40    Baseline     1
 41 41    Baseline    32
 42 42    Baseline     4
 43 43    Baseline     1
 44 44    Baseline    64
 45 45    Baseline    64
 46 46    Baseline     4
 47 47    Baseline     1
 48 48    Baseline    64
 49 49    Baseline    64
 50 50    Baseline    32
 51 51    Baseline     1
 52 52    Baseline     1
 53 53    Baseline    16
 54 54    Baseline   512
 55 55    Baseline    32
 56 1     Month 1     32
 57 2     Month 1    512
 58 3     Month 1     16
 59 4     Month 1    256
 60 5     Month 1    128
 61 6     Month 1    256
 62 7     Month 1    512
 63 8     Month 1     32
 64 9     Month 1    256
 65 10    Month 1     32
 66 11    Month 1    256
 67 12    Month 1    256
 68 13    Month 1    512
 69 14    Month 1    256
 70 15    Month 1    256
 71 16    Month 1    256
 72 17    Month 1    256
 73 18    Month 1    256
 74 19    Month 1     NA
 75 20    Month 1   2048
 76 21    Month 1    512
 77 22    Month 1    128
 78 23    Month 1    256
 79 24    Month 1    256
 80 25    Month 1     NA
 81 26    Month 1     64
 82 27    Month 1   1024
 83 28    Month 1    128
 84 29    Month 1    512
 85 30    Month 1    128
 86 31    Month 1    256
 87 32    Month 1    512
 88 33    Month 1   1024
 89 34    Month 1     64
 90 35    Month 1     NA
 91 36    Month 1    512
 92 37    Month 1    128
 93 38    Month 1     NA
 94 39    Month 1    256
 95 40    Month 1    128
 96 41    Month 1    512
 97 42    Month 1    256
 98 43    Month 1   1024
 99 44    Month 1    128
100 45    Month 1    256
101 46    Month 1    128
102 47    Month 1    256
103 48    Month 1     NA
104 49    Month 1    256
105 50    Month 1    128
106 51    Month 1     32
107 52    Month 1    128
108 53    Month 1    256
109 54    Month 1     64
110 55    Month 1     64
111 1     Month 18   128
112 2     Month 18    16
113 3     Month 18     4
114 4     Month 18     2
115 5     Month 18    NA
116 6     Month 18    NA
117 7     Month 18   256
118 8     Month 18     1
119 9     Month 18    64
120 10    Month 18     1
121 11    Month 18    64
122 12    Month 18    NA
123 13    Month 18    64
124 14    Month 18    16
125 15    Month 18     2
126 16    Month 18    NA
127 17    Month 18   128
128 18    Month 18    32
129 19    Month 18    NA
130 20    Month 18    NA
131 21    Month 18     8
132 22    Month 18     4
133 23    Month 18     4
134 24    Month 18   256
135 25    Month 18    NA
136 26    Month 18    NA
137 27    Month 18    16
138 28    Month 18     2
139 29    Month 18     1
140 30    Month 18     2
141 31    Month 18    NA
142 32    Month 18   128
143 33    Month 18    NA
144 34    Month 18     4
145 35    Month 18    NA
146 36    Month 18    32
147 37    Month 18   128
148 38    Month 18    NA
149 39    Month 18    64
150 40    Month 18     2
151 41    Month 18    64
152 42    Month 18    16
153 43    Month 18     2
154 44    Month 18    64
155 45    Month 18    NA
156 46    Month 18     2
157 47    Month 18    32
158 48    Month 18    NA
159 49    Month 18    64
160 50    Month 18    64
161 51    Month 18     1
162 52    Month 18     2
163 53    Month 18    64
164 54    Month 18    NA
165 55    Month 18    32
166 1     Month 30    32
167 2     Month 30    32
168 3     Month 30     4
169 4     Month 30     4
170 5     Month 30    NA
171 6     Month 30    NA
172 7     Month 30   256
173 8     Month 30     2
174 9     Month 30    NA
175 10    Month 30    NA
176 11    Month 30    NA
177 12    Month 30    NA
178 13    Month 30    64
179 14    Month 30     4
180 15    Month 30     4
181 16    Month 30    NA
182 17    Month 30    64
183 18    Month 30     8
184 19    Month 30    NA
185 20    Month 30    NA
186 21    Month 30     8
187 22    Month 30     4
188 23    Month 30     8
189 24    Month 30    NA
190 25    Month 30    NA
191 26    Month 30    NA
192 27    Month 30    64
193 28    Month 30     2
194 29    Month 30    NA
195 30    Month 30     4
196 31    Month 30    NA
197 32    Month 30    NA
198 33    Month 30    NA
199 34    Month 30     4
200 35    Month 30    NA
201 36    Month 30    16
202 37    Month 30    64
203 38    Month 30    NA
204 39    Month 30   128
205 40    Month 30     1
206 41    Month 30    32
207 42    Month 30    16
208 43    Month 30    NA
209 44    Month 30    16
210 45    Month 30    NA

Code:

y_limits<-c(1,2,4,8,16,32,64,128,256,512,1024,2048)
pd <- position_dodge2(width=0.5)

ggplot(NadA, aes(x= Time,y= GMT, fill= Time, group= ID)) +
  geom_point(position= pd, shape= 21, size=2, alpha= 0.7)+
  geom_line(position=pd, alpha= 0.3) +
  scale_y_log10(breaks = y_limits) +
  theme_classic() + theme(legend.position = "none")

I need all dots to stay at the same Y height (otherwise this would mean a higher/lower GMT level) therefore jitter wouldn't work here. I tried geom_boxplot but I couldn't get the dots/lines to match.

Any ideas would be much appreciated!

Upvotes: 0

Views: 40

Answers (0)

Related Questions