I am trying to make a graph with greek letters in the legend and bold characters in the legend of the x-axis. This works fine with ggplot:
library(ggplot2)
library(plotly)
## Dataframe
df <- data.frame(dose=c("D0.5", "D1", "D2"),len=c(4.2, 10, 29.5))
## Legend with the greek letter pi
my.labs <- list(bquote(Pi==.(5)) )
## Plot with ggplot
p=ggplot(data=df, aes(x=dose, y=len, group=1,colour = paste("Pi = ",5,sep=""))) +
geom_line()+
geom_point()+
scale_colour_manual(values=3, labels=my.labs)+
theme(legend.title=element_blank(), legend.position = c(.1, .9),axis.title.x = element_text(face="bold", colour="black", size=10))
p
However the greek letter and the bold legend for the x-axis disappear when using plotly:
p=plotly_build(p)
style( p, hoverinfo = "x+y" ) %>%
layout( legend = list(x = 0.1, y = 0.9, font=list(size=12)) )