r语言 - 在制作 ggplot 轴标题时,如何写 £^-1?



我正试图用£^-1标记我的绘图轴。它似乎没有产生所需的输出。

我的yaxis代码是:

ylab(bquote('Carbon cost of earning ('*g.£^-1*')'))+

我收到错误:

Error: Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?
Run `rlang::last_error()` to see where the error occurred.

但如果以运行,则代码相同

ylab(bquote('Carbon cost of earning ('*g.GBP^-1*')'))+

我能够得到想要的输出。关于如何使英镑符号出现,有什么建议吗?

bquote中的字符串需要用波浪号分隔符括起来的引号。所以试试

ylab(bquote("Carbon cost of earning (g.£"^-1 ~")"))

我找到了一种结合unicode来完成任务的方法。我补充道:

labs(y="Carbon cost of earning (g.£U207BU00B9)")+

最新更新