@@ -128,12 +128,17 @@ add_annotations_to_plot_pp <- function(p,
128128 if (annotation_arrows ) {
129129
130130 p_annotated <- p + ggrepel :: geom_text_repel(
131+ data = . %> % dplyr :: filter(series %in% c(" cl" ),
132+ ! is.na(annotation_level )),
131133 ggplot2 :: aes(x = x ,
132- y = cl ,
134+ y = value ,
133135 label = cl_label ),
134- position = ggpp :: position_nudge_to(y = df %> %
135- dplyr :: filter(! is.na(y )) %> %
136- dplyr :: pull(annotation_level )),
136+ position = ggpp :: position_nudge_to(
137+ y = df %> %
138+ dplyr :: filter(series %in% c(" cl" ),
139+ ! is.na(value ),
140+ ! is.na(annotation_level )) %> %
141+ dplyr :: pull(annotation_level )),
137142 color = " grey40" ,
138143 size = annotation_size ,
139144 fontface = " bold" ,
@@ -143,7 +148,9 @@ add_annotations_to_plot_pp <- function(p,
143148 hjust = 0 ,
144149 segment.size = 0.75 ,
145150 segment.curvature = df %> %
146- dplyr :: filter(! is.na(y )) %> %
151+ dplyr :: filter(series %in% c(" cl" ),
152+ ! is.na(value ),
153+ ! is.na(annotation_level )) %> %
147154 dplyr :: pull(annotation_curvature ),
148155 segment.ncp = 4 ,
149156 segment.inflect = FALSE ,
@@ -153,12 +160,17 @@ add_annotations_to_plot_pp <- function(p,
153160 max.overlaps = Inf )
154161 } else {
155162 p_annotated <- p + ggrepel :: geom_text_repel(
163+ data = . %> % dplyr :: filter(series %in% c(" cl" ),
164+ ! is.na(annotation_level )),
156165 ggplot2 :: aes(x = x ,
157- y = cl ,
166+ y = value ,
158167 label = cl_label ),
159- position = ggpp :: position_nudge_to(y = df %> %
160- dplyr :: filter(! is.na(y )) %> %
161- dplyr :: pull(annotation_level )),
168+ position = ggpp :: position_nudge_to(
169+ y = df %> %
170+ dplyr :: filter(series %in% c(" cl" ),
171+ ! is.na(value ),
172+ ! is.na(annotation_level )) %> %
173+ dplyr :: pull(annotation_level )),
162174 color = " grey40" ,
163175 size = annotation_size ,
164176 fontface = " bold" ,
@@ -184,14 +196,17 @@ add_annotations_to_plot_basic <- function(p,
184196 x_nudge <- x_range / 25
185197
186198 p_annotated <- p +
187- ggplot2 :: geom_text(mapping = ggplot2 :: aes(x = x ,
188- y = annotation_level ,
189- label = cl_label ),
190- nudge_x = x_nudge ,
191- na.rm = TRUE ,
192- color = " grey40" ,
193- size = annotation_size ,
194- fontface = " bold" )
199+ ggplot2 :: geom_text(
200+ data = . %> % dplyr :: filter(series %in% c(" cl" ),
201+ ! is.na(annotation_level )),
202+ mapping = ggplot2 :: aes(x = x ,
203+ y = annotation_level ,
204+ label = cl_label ),
205+ nudge_x = x_nudge ,
206+ na.rm = TRUE ,
207+ color = " grey40" ,
208+ size = annotation_size ,
209+ fontface = " bold" )
195210
196211 return (p_annotated )
197212
0 commit comments