How to add a superscript or a subscript to an axis label to a 3D plot in plotly?
I tried to use bquote
, but it did not work. 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:
yaxis = list(title = "Sin<sup>super</sup>")
More info here. Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With