I have a list of dataframes. The dataframes have the columns: Dist
, GPSSpeed_kmh
. I want to plot a png of the left-bend sign in a specific point of the plot. I used the following code for the dataframe df
and the result is shown below:
ggplot(df, aes(Dist, GPSSpeed_kmh)) +
geom_point(size = 1) +
geom_smooth(se = TRUE, span = 0.7) +
scale_x_continuous(limits = c(-20,11),breaks = seq(-30, 10, by = 10), labels = abs(breaks)) +
geom_vline(xintercept = -16) +
annotation_custom(leftbend, xmin = -18, xmax = -14, ymin = 30, ymax = 40)
But when I use another dataframe the leftbend icon is plotted in another point because the arguments ymin
,ymax
depend on the input dataframe in order to plot the leftbend icon above the geom_vline()
(xmin
, xmax
are fixed).
Is there a way for the arguments ymin
,ymax
to be adjusted in the input dataframe? I want to have a common output result for all my dataframes.
Thank you in advance!
*if I use another dataframe the result is the following:
The icon is even not plotted because this dataframe don't have GPSSpeed_kmh
values from 30 (ymin) to 40 (ymax) as the other have!