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.

https://drive.google.com/file/d/0b50v8ccfhjdqwf94sg85nxvzy1k/view?usp=sharing

for using textxy() in calibrate package

however when multiple peaks occur things more complicated:

https://drive.google.com/file/d/0b50v8ccfhjdqumf5verhuv8znmc/view?usp=sharing

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) 

enter image description here

## rotate labels 90 degree plot(p, ylim=c(0, 30000)) labelpeaks(p, underline=false, srt=90, adj=c(0, 0.5), col="red") 

enter image description here

## label peaks above 5000 plot(p, ylim=c(0, 30000)) labelpeaks(p, index=intensity(p) > 5000) 

enter image description here

please see ?labelpeaks more details.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -