Draw line from Label to point in R -
i trying generate automated script create labeled line graph. line graphs have 1 or more maxima if above threshold must labeled. can label maxima fine.
for using textxy() in calibrate package
however when multiple peaks occur things more complicated:
it becomes difficult see label assigned to. line label top (or below) of peak.
i've looked around day today no luck. tried in intelligent point label placement in r
wordcloud, unfortunately doesn't allow offset labels, , fails if have 1 label.
identify, slow. need able automate thousands of images day.
pointlabel, thigmophobe.labels both didn't work don't draw line, , not dealing lots of labels anyway.
i tried manually drawing arrow between label , point, got time consuming.
does know of package or easy way this? not possible automate?
thanks! cameron
you can try labelpeaks
function provided maldiquant
package. algorithm place peak labels taken ian fellows' wordcloud::wordlayout
.
library("maldiquant") data("fiedler2009subset") ## simplified preprocessing provide example data s <- trim(fiedler2009subset[[1]], c(3000, 3500)) r <- removebaseline(s) p <- detectpeaks(r) ## plot peaks , label them plot(p, ylim=c(0, 30000)) labelpeaks(p, avoidoverlap=true, underline=false, digits=1)
## rotate labels 90 degree plot(p, ylim=c(0, 30000)) labelpeaks(p, underline=false, srt=90, adj=c(0, 0.5), col="red")
## label peaks above 5000 plot(p, ylim=c(0, 30000)) labelpeaks(p, index=intensity(p) > 5000)
please see ?labelpeaks
more details.
Comments
Post a Comment