How to change fontsize in direct.label?

非 Y 不嫁゛ 提交于 2019-12-03 05:44:59

I figured it out, you use cex to change the font size.

df <- data.frame(x = rnorm(26), y=rnorm(26), let=letters)
p <- ggplot(df, aes(x, y, color=let)) + geom_point() 
direct.label(p, 
    list("top.points", rot=45, cex=6, 
          fontface="bold", fontfamily="serif", alpha=0.5))

That would give you,

It's kind of a different route, but would you consider doing it all in ggplot2?

ggplot(df, aes(x, y, color=let)) + 
       geom_point() + 
       geom_text(df, mapping=aes(x, y, label=let, colour=let), 
       size=5, vjust=-.55, hjust=.55, angle = 45, fontface="bold", 
       family ="serif", alpha=0.5) + opts(legend.position = "none")

This would give you this, and you can adjust the fontsize using size

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