简体   繁体   中英

How to cleanly label the points in a simple ggplot2 scatterplot?

See the examples from http://had.co.nz/ggplot2/geom_text.html ; they're pretty terrible. Labels overlap each other, run outside the plot, etc.

I thought directlabels might help, but it doesn't really:

direct.label(qplot(wt,mpg,data=mtcars,colour=rownames(mtcars)))

Manually positioning each label is tedious. Hoping there's something that makes labels a bit more usable. Anything that might fit the bill?

hope it's not too late for the answer. I don't now about ggplot2, I used normal scatterplots using plot(). I tried many labelling algorithms, and the best was pointLabel() from package maptools with wrapping the labels by spaces:-)

pointLabel(x, y, labels = paste("  ", point_names, "  ", sep="")

I tried thigmophobe.labels() from package plotrix, textxy() from package calibrate or standard text(), but I think pointLabel() was best.

But anyway for my purpose I ended up to simply use identify() and I just clicked the points for which I wanted the label - very useful, you just click the outliers and some interesting points that's it!!

Tomas

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM