我正试着在我的一本书中用R/Plotly写下摄氏度这个符号。当我只使用下面的一个简单的绘图时,它是有效的:
# Working code
library(latex2exp)
set.seed(1)
betas <- rnorm(1000)
hist(betas, main = TeX("Temperature (^0C)"))
然而,当我试图通过绘图运行代码时,我得到了以下错误:“‘HashTableSetup’中的'expression‘未实现类型”。
#Initialise the plot
p <- plot_ly()
#Add axis names
#Font
f <- list(
family = "Courier New, monospace",
size = 18,
color = "#7f7f7f")
#X axis name
x <- list(
title = "x Axis",
titlefont = f)
#Y Axis name
y <- list(
title = TeX("Temperature (^0C)"),
titlefont = f)
#Add layout
p <- p %>%
layout(xaxis = x, yaxis= y)
p
有什么想法吗?
发布于 2018-08-11 19:23:19
我刚刚找到了一个棘手的解决方案:在google上查找特殊字符,然后将其直接复制粘贴到R代码中。
#Y Axis name
y <- list(
title = "Temperature (°C)",
titlefont = f)
我仍然对一种不那么麻烦的解决方案感兴趣,它允许将LaTeX插入到Plotly中。
发布于 2018-08-11 19:23:02
试一下,
title = "Temperature (\u00B0C)"
发布于 2018-08-11 19:27:10
尝试使用title = expression("Temperature ("*~degree*C*")")
或title = "Temperature (°C)"
https://stackoverflow.com/questions/51799118
复制相似问题