When using ArcGIS to make maps, the software by default pushes point and polygon labels around automatically to avoid overlap using a proprietary algorithm. They refer to this as dynamic labeling. ggplot2
has position_jitter
which is excellent for points (since dynamic labeling might create systematic bias), but less good for labels using geom_text
.
Here's an example of some problems with jitter that a dynamic labeling algorithm might solve:
library(ggplot2)
ggplot( mtcars,aes( x=wt, y=mpg, label=rownames(mtcars) ) ) +
geom_point() +
geom_text( position=position_jitter(h=1,w=1) )
Does such a dynamic labeling feature exist already in ggplot2?
If not, what algorithms exist for doing so and is it possible to implement a position_dynamic
in R?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…