首页 > 解决方案 > 使用闪亮的输入、文本和希腊字母向 ggplot 添加标题

问题描述

我想将以下标题添加到 ggplot:

"Number of times where UK emissions of Sulphur Dioxide exceeded 10 microgrammes per metre cubed"

这个标题的组成部分来自:

free text = "Number of times where UK emissions of "
input$select = Sulphur Dioxide (or any other pollutant the user selects)
free text = "exceeded "
input$number = 10 (or any other integer the user selects)
formula = μg/m3 (where the 3 is superscript of m)

使用了粘贴和表达式以及 bquote 的组合,但它只是不正确。

这是我上面的代码....

ggplot() + 
aes(x=year, y=cnt) +
labs(title = paste("Number of times where UK emissions of ", input$select, 
   " exceeded", input$number, expression(mu), "g/m", "^{3}"))

标签: rggplot2

解决方案


我不确定你在问什么,但如果你用它"\u03BCg/m\u00B3"μg/m³打印它会很好地打印出来。


推荐阅读