如何将图标的上标或下标添加到3D图中?

时间:2017-07-24 13:52:52

标签: r plot plotly

如何将图标的上标或下标添加到3D图中?

我尝试使用bquote,但它没有用。谷歌搜索也没有带来太多关于此事。

清除代码:

library(plotly)
set.seed(123)

n <- 100
theta <- runif(n, 0, 2*pi)
u <- runif(n, -1, 1)


base<-'B1'
compare<-'A1'
plot (1, 1, main = bquote('Annual mean' ~CO[2] ~'Flux Difference: \n'  ~.(compare)~ 'minus'~.(base)))


p <- plot_ly(x = ~sqrt(1 - u^2) * cos(theta), y = ~sqrt(1 - u^2) * sin(theta), z = ~u) %>%
  layout(
    title = "Layout options in a 3d scatter plot",
    scene = list(
      xaxis = list(title = bquote('Annual mean' ~CO[2] ~'Flux Difference: \n'  ~.(compare)~ 'minus'~.(base))),
      yaxis = list(title = "Sin"),
      zaxis = list(title = "Z")
    ))
p

感谢您的时间!

1 个答案:

答案 0 :(得分:4)

使用HTML标记,例如:

yaxis = list(title = "Sin<sup>super</sup>")

更多信息here。希望这有帮助!

enter image description here