gpt4 book ai didi

r - 如何增加标签名称的字体大小

转载 作者:行者123 更新时间:2023-12-04 12:34:46 25 4
gpt4 key购买 nike

我想增加标签名称的字体大小。我试过 geom_label_repel(aes(label = names, label.size = 5), box.padding = unit(0.5, "lines")) .但大小不影响标签。

ggplot(df, aes(x,y,label=names)) +
geom_point(colour = "red", size = 3) +
geom_smooth(method=lm, se=FALSE, colour = "blue") +
geom_label_repel(aes(label = names, label.size = 5),
box.padding = unit(0.5, "lines")) +
xlim(0,2.5) +
ylim(0,2.5) +
theme( plot.title=element_text(size=16,face="bold"),
axis.text=element_text(size=18),
axis.title=element_text(size=20,face="bold"))

最佳答案

正如我刚刚在评论中所写,从您的代码中不清楚您是希望标签大小是固定的(所有标签都相同)还是依赖于 df 的列。 .猜你想修复它。在这种情况下,设置大小为 不是 aes(...) 内完成.另外,没有必要重复label=names .阅读后https://cran.r-project.org/web/packages/ggrepel/vignettes/ggrepel.html我们可以这样写:

ggplot(df, aes(x,y,label=names)) +
geom_point(colour = "red", size = 3) +
geom_smooth(method=lm, se=FALSE, colour = "blue") +
geom_label_repel(size = 5,
box.padding = unit(0.5, "lines")) +
xlim(0,2.5) +
ylim(0,2.5) +
theme( plot.title=element_text(size=16,face="bold"),
axis.text=element_text(size=18),
axis.title=element_text(size=20,face="bold"))

关于r - 如何增加标签名称的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37023083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com