Writing the symbol degrees celsius in axis titles with R/plotly

I'm trying to write the symbol degrees celsius with R/Plotly in one of my titles. It works when I just use a simple plot a below:

# Working code library(latex2exp) set.seed(1) betas <- rnorm(1000) hist(betas, main = TeX("Temperature (^0C)")) 

However, when I try to run the code through plotly, I get the following error: "unimplemented type 'expression' in 'HashTableSetup'".

#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 

Any ideas?

3 Answers

Try,

title = "Temperature (\u00B0C)" 
1

Try title = expression("Temperature ("*~degree*C*")") or title = "Temperature (°C)"

I just found a hacky solution: Look for the special character on google and copy and paste it directly in the R code.

#Y Axis name y <- list( title = "Temperature (°C)", titlefont = f) 

I'm still interested in a less hacky solution which allows to insert LaTeX into Plotly.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like