简体   繁体   English

如何在plotly中的3D图的轴标签上添加上标或下标?

[英]How to add a superscript or a subscript to an axis label to a 3D plot in plotly?

How to add a superscript or a subscript to an axis label to a 3D plot in plotly? 如何在plotly中的3D图的轴标签上添加上标或下标?

I tried to use bquote , but it did not work. 我尝试使用bquote ,但是没有用。 Googling did not bring much on the matter either. 谷歌搜索也没有带来太多的事情。

Scavenged code: 清除代码:

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

Thank you for your time! 感谢您的时间!

With HTML tags, for example: 以HTML标记为例:

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

More info here . 更多信息在这里 Hope this helps! 希望这可以帮助!

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM