When converting a ggplot graphics to a plotly graphics with ggplotly, I can get some HTML, for example in the title:
library(plotly)
library(ggplot2)
library(scales)
library(mvtnorm)
sims <- rmvnorm(500, mean=c(0,0,0))
dat <- setNames(data.frame(sims), c("x", "y", "z"))
dat$z <- dat$x+dat$y
gg <- ggplot(dat, aes(x=x, y=y, colour=z)) +
geom_point() +
scale_colour_gradient2(limits=c(-2,2), midpoint=0, low=muted("blue"), high=muted("red")) +
ggtitle("<em>hello</em>")
ggplotly(gg)

The title <em>hello</em> appears in italic, as expected.
But when I want a HTML greek letter, that does not work:
gg <- ggplot(dat, aes(x=x, y=y, colour=z)) +
geom_point() +
scale_colour_gradient2(limits=c(-2,2), midpoint=0, low=muted("blue"), high=muted("red")) +
ggtitle("Δ")
ggplotly(gg)

How to render Δ as the expected greek letter ?
I'm using plotly_4.5.2 and ggplot2_2.1.0.
This works with the decimal character reference:
gg <- ggplot(dat, aes(x=x, y=y, colour=z)) +
geom_point() +
scale_colour_gradient2(limits=c(-2,2), midpoint=0, low=muted("blue"), high=muted("red")) +
ggtitle("Δ")
ggplotly(gg)
According to this comment on the Github repo, plotly.js recently removed generalized HTML entity decoding". I'm not sure to understand, but it could be the explanation.
The plotly developers have now removed the html decimal character encoding. As a solution, one can directly enter an UTF-8 character, or use intToUtf8:
ggtitle("Δ")
ggtitle(intToUtf8(0x0394L))
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