Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 297
Liky Avatar asked Aug 11 '18 11:08

Liky


People also ask

How do you write degrees in R?

The symbol for degrees Rankine is °R (or °Ra if necessary to distinguish it from the Rømer and Réaumur scales). By analogy with the SI unit, the kelvin, some authors term the unit Rankine, omitting the degree symbol.

How do you type the degree symbol in coordinates?

Insert the degree symbol by using a keyboard shortcut On your keyboard, press Alt + 0176. Note: This method works only for keyboards that include a 10-key numeric pad.

How do you write Celsius?

The degree Celsius (symbol: °C) can refer to a specific temperature on the Celsius scale or a unit to indicate a difference or range between two temperatures. It is named after the Swedish astronomer Anders Celsius (1701–1744), who developed a similar temperature scale in 1742.


1 Answers

Try,

title =  "Temperature (\u00B0C)"
like image 156
Lyngbakr Avatar answered Oct 08 '22 04:10

Lyngbakr