在ggplot中的y-label上方添加其他文本

问题描述 投票:0回答:1

我正在做大图比较预测模型。但是如何将其他文本添加到标签?例如,这是我需要在y标签旁边添加其他文本的情节之一。

(qplot(y = VaR90_n_roll1, x = 507:1006, geom = 'line')
                     + geom_line(color = 'green')
                     + geom_point(aes(x = 507:1006, y = sp500_logreturns[507:1006]))
                     + coord_cartesian(ylim = c(-0.065,0.05))
                     + labs(y = c('Log returns', 
                            'Model 1'), x = '')
                     + ggtitle("")
                     + theme(plot.title = element_text(hjust = 0.5)))

哪个给我这个:enter image description here

但是我需要这个:enter image description here

r ggplot2
1个回答
2
投票

这是您要寻找的吗?

``` r
library(ggplot2)

ggplot(mtcars, aes(wt, mpg))+
  geom_point()+
  labs(y = expression(atop(bold(Log~returns), Model)))+
  theme(axis.title.y = element_text(size = 14))

“”

reprex package(v0.3.0)在2020-05-24创建

© www.soinside.com 2019 - 2024. All rights reserved.