【问题标题】:How can I change the text size of directlabels on a ggplot graph?如何更改 ggplot 图上直接标签的文本大小?
【发布时间】:2012-04-30 05:37:33
【问题描述】:

我正在尝试使用directlabels 将标签应用于套索图,如here 所示。我可以将标签放在页面上,但无法更改大小。在列表中传递其他参数允许我更改其他元素,但不能更改文本大小。

require(ggplot2)
require(directlabels)
dat_test <- data.frame(x=1:10, value=c(sin(1:10), cos(1:10), tan(1:10)), fun=rep(c('sin', 'cos', 'tan'), each=10))
p <- ggplot(dat_test, aes(x=x, y=value, group=fun, colour=fun)) + geom_line()

direct.label(p, 'last.qp') # adds labels
direct.label(p, list('last.qp', size=2)) # does not work, same as above
direct.label(p, list('last.qp', rot=30)) # correct rotates text

是否可以更改直接标签的文字大小?

【问题讨论】:

    标签: r ggplot2 direct-labels


    【解决方案1】:

    用途:

    direct.label(p, list('last.qp', cex=2)) 
    

    【讨论】:

    • 谢谢,虽然 cex=2 实际上让它变大了; cex=0.75 正是我想要的。我没想到基本选项会产生这种效果。您知道这些类型的选项是否记录在某处?
    猜你喜欢
    • 2020-01-01
    • 2011-03-03
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 2019-11-18
    • 1970-01-01
    • 2016-05-28
    • 2012-10-14
    相关资源
    最近更新 更多