包含数学 $\\times$ 符号的绘图标题

Ivo*_*Ivo 6 latex r ggplot2

我想在绘图标题中包含乘法的数学符号(例如小写的 x)。

我尝试过latex2exp但没有成功 - 有人可以帮助我吗?

代表代码是这样的:

library(ggplot2)
library(latex2exp)
ggplot(data = data.frame(number = round(rnorm(200, mean=55, sd=5))),
       aes(x = number)) + geom_density() +
  ggtitle(TeX("Title containing times sign here: $\\times$"))
Run Code Online (Sandbox Code Playgroud)

它产生这样的结果:

在此输入图像描述

我希望正方形(表示无法识别的标志)显示为以下标志:在此输入图像描述。似乎其他标志可以使用这种方法(例如阿尔法),但我无法弄清楚为什么该times标志会造成问题。

我不打算使用 Latex2exp 作为解决方案,只要它适用于 Latex 字体(LM Roman 10)即可。

预先非常感谢。

use*_*330 8

它对我来说很实用plotmath%*%操作员显示为时间符号。例如,

library(ggplot2)
ggplot(data = data.frame(number = round(rnorm(200, mean=55, sd=5))),
       aes(x = number)) + geom_density() +
  ggtitle(expression("Title containing times sign here: " %*% ""))
Run Code Online (Sandbox Code Playgroud)

reprex 包(v2.0.0)于 2021-06-14 创建

我认为这就是我们latex2exp想要做的,所以可能是您的系统上缺少时代符号,这就是您收到该框的原因。有趣的是 Unicode 解决方案有效。


Ian*_*ell 6

一种方法可能是使用 unicode 代码作为乘法符号

library(ggplot2)
ggplot(data = data.frame(number = round(rnorm(200, mean=55, sd=5))),
       aes(x = number)) + geom_density() +
  ggtitle("Title containing times sign here: \u00D7")
Run Code Online (Sandbox Code Playgroud)

可以将 Unicode 字符添加到具有\u4 个十六进制代码的任何字符串中。您可以从您的操作系统或通过 Google 找到适当的代码。