gpt4 book ai didi

r - 将 ggplot 标题定位在图的右上角

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

我正在使用优秀的 theme_minimal()在白色背景的 ggplot0.9.3 中找到。我想将我的情节的标题放在情节右上角的自定义位置。在下面的例子中,我知道 xy值,但我想知道是否有办法通过 xmaxymax值以确保文本放置在右上角。理想情况下,文本应正确对齐。

#example plot
p <- qplot(mpg, wt, data = mtcars, colour = cyl)
p + annotate("text", x = 30, y = 5, label = "Custom Title")

#what I would like
p + annotate("text", y= ymax, x =xmax_or_RightJustified)

最佳答案

你可以做

p + annotate("text",  x=Inf, y = Inf, label = "Some text", vjust=1, hjust=1)

关于r - 将 ggplot 标题定位在图的右上角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14928711/

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