【发布时间】:2017-11-10 05:13:53
【问题描述】:
我正在尝试使用图例中的希腊字母和 x 轴的图例中的粗体字符制作图表。这适用于 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
但是,当使用 plotly 时,x 轴的希腊字母和粗体图例会消失:
p=plotly_build(p)
style( p, hoverinfo = "x+y" ) %>%
layout( legend = list(x = 0.1, y = 0.9, font=list(size=12)) )
【问题讨论】: