R ggplot2在标题中添加今天的日期 [英] R ggplot2 Add today's date to the title
本文介绍了R ggplot2在标题中添加今天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
原则上,我敢肯定这很简单....
In principle, I'm sure this is straightforward....
如何将今天的日期附加到我的ggplot标题上?
How do I append today's date to my ggplot title?
today.date <- Sys.Date()
labs(title='Daily New COVID-19 Hospitalizations as of ', x=....)
换句话说,今天/日期追加到我的绘图标题的R/ggplot语法是什么?我最好使用ggtitle而不是lab作为标题-这样会更容易吗?
In other words, what's the R / ggplot syntax to append today.date to my plot title? Am I better off using ggtitle rather than labs for the title -- does that make it easier?
谢谢!
推荐答案
同时使用 labs
和 ggtitle
,您可以使用函数 paste()
如下:
Both with labs
and ggtitle
you can use function paste()
as follows:
labs(title = paste('Daily New COVID-19 Hospitalizations as of', today.date, sep = " "))
或
ggtitle(paste('Daily New COVID-19 Hospitalizations as of', today.date, sep = " "))
这篇关于R ggplot2在标题中添加今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文