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)" 1Try 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.