如何更改direct.label中的字体大小? [英] How to change fontsize in direct.label?

查看:215
本文介绍了如何更改direct.label中的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法更改direct.label中的字体大小(来自直接标签包)ggplot2图。请参阅下面的可重现示例 - 旋转45度标签没有问题,使它们变为粗体,衬线和50%透明(下面代码末尾的列表中的所有其他参数) - 但我无法控制字体大小。 (我真的不希望他们是25,这只是为了测试......)

有什么我丢失的,或者这是一个错误?

  library(ggplot2)
library(scales)
library(directlabels)
df < - data.frame(x = rnorm(26),y = rnorm(26),let =字母)
p <-ggplot(df,aes(x,y,color = let))+ geom_point )
direct.label(p,
list(top.points,rot = 45,fontsize = 25,
fontface =bold,fontfamily =serif,alpha = 0.5 ))


解决方案

c $ c> cex 改变字体大小。

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

这会给你,


I can't change the fontsize in a direct.label (from the directlabels package) ggplot2 plot. See below for a reproducible example - there's no problem in rotating the labels 45 degrees, making them bold, serif, and 50% transparent (all the other arguments in the list at the end of the code below) - but I can't control the fontsize. (I don't really want them to be 25, this is just for testing....)

Is there something I'm missing, or is this a bug?

library(ggplot2)
library(scales)
library(directlabels)
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, fontsize=25, 
        fontface="bold", fontfamily="serif", alpha=0.5))

解决方案

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,

这篇关于如何更改direct.label中的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆