I am working on a plot that will have the data curve, a png image inset, as well as annotations. However, every time I add my inset image all of my annotations disappear and I'm not sure what I am doing wrong. Help would be greatly appreciated! I still need to work on my axis labels and such but am stuck here! Additionally, if anyone has any style tips or recommendations I am all ears!
o18 <- data.frame(Sample=1:20, O18 = c(.41,.3, .42,.22, .45,.61, 1.15, 1.77,2.05,
1.93,1.72,1.46,1.25, 1.09,1.38,1.96, 2.23,
1.93, 1.56,1.42))
library(png)
oto_ill <- readPNG('otolith_illustration.png', native = TRUE)
library(patchwork)
o18.plot2 <- ggplot(data=o18, aes(x=Sample, y = O18)) +
geom_line(colour='NA') +
theme_classic()+
geom_smooth(method="loess", span=0.2)+
inset_element(oto_ill, left =0.01, right =0.3, bottom = 0.4, top =1)+
annotate(geom="text", x=3, y=2.6, label="otolith", size=4, color='black',
parse=TRUE)+
annotate(geom="text", x=9, y=2.4, label="1st winter" , size=4, color='black',
parse=FALSE)+
annotate(geom="text", x=17, y=2.6, label="2nd winter", size=4, color='black',
parse=FALSE)+
annotate("segment", x = 9, xend = 9, y = 2.3, yend = 2.1, colour = "black", size=3, alpha=0.6, arrow=arrow())+
annotate("segment", x = 17, xend = 17, y = 2.5, yend = 2.3, colour = "black", size=3, alpha=0.6, arrow=arrow())
o18.plot2