Label size in directlabels geom_dl()

微笑、不失礼 提交于 2019-12-06 20:58:19

问题


I have really enjoyed the package directlabels for dynamic positioning the lables of a plot. Although still not perfect, it helps reasonably to prevent overlaps between labels of a scatter plots with many points for example - specially for the draft version of the charts, not the final one.

However I can not find anyway to change the label size while using geom_dl() function. Is there anyway?

I have tried to pass size and cex as a normal or aes() argument to the function.


回答1:


Put cex inside a list. Other formatting features should also be placed in the list. See some of the examples in ?directlabels::geom_dl

library(ggplot2)
library(directlabels)

dat = data.frame(x = 1:10, y = 1:10, z = letters[1:10])

ggplot(dat, aes(x, y)) +
    geom_point() +
    geom_dl(aes(label = z), method = list(cex = 2, rot = -45, hjust = -.5))

EDIT

The method too is placed in the list:

ggplot(dat, aes(x, y)) +
    geom_point() +
    geom_dl(aes(label = z), method = list("smart.grid", cex = 2))


来源:https://stackoverflow.com/questions/13242436/label-size-in-directlabels-geom-dl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!