Hi everyone,
The question is quite simple; is there away to make plot_ly add_annotation prevent annotation overlap?
plot_ly(x = spectralg[[1]]@mass, y = spectralg[[1]]@intensity, name = 'spectra 1', type = 'scatter', mode ='lines',
color = I(13)) %>%
layout(title = 'peaks 1 and 2',
xaxis = list(title = 'm/z', range = c(500, 1800)),
yaxis = list(title = 'Intensity',range = c(-100, 100)))%>%
add_trace(data = peaks[[1]], x =peaks[[1]]@mass, y=peaks[[1]]@intensity, name = 'peaks 1', mode = 'markers', color = I('orange'))%>%
add_trace(data = spectralg[[2]], x = spectralg[[2]]@mass, y=-spectralg[[2]]@intensity, name = 'spectra 2', mode = 'lines',color = I('green'))%>%
add_trace(data = peaks[[2]], x =peaks[[2]]@mass, y=-peaks[[2]]@intensity, name = 'peaks 2', mode = 'markers', color = I('red'))%>%
add_trace(x = nunmz1, y = nunint1, name = 'Common peaks', mode = 'markers', color = I('Black'))%>%
add_trace(x = nunmz2, y = -nunint2, name = 'Common peaks', mode = 'markers', color = I('Black'))%>%
add_annotations(x =peaks[[1]]@mass, y=peaks[[1]]@intensity, text = as.character(round(peaks[[1]]@mass), 6), xref = "x",
yref = "y",
textangle = 270,
front = list( size = 2),
opacity =1,
textposition = 'top center')
There are many labels close together and I need them to be clear without zooming to infinity.