0
我想在传说中的希腊字母和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
然而希腊字母,为x轴的大胆Legend采用plotly时消失:
p=plotly_build(p)
style(p, hoverinfo = "x+y") %>%
layout(legend = list(x = 0.1, y = 0.9, font=list(size=12)))
感谢@Maximilian!不幸的是,pi的HTML代码似乎不适合我。我只是得到一个带有“π = 5”的传奇。你会对此有任何建议吗? 谢谢! 这是我的sessionInfo:R版本3.3.3(2017-03-06) 平台:x86_64-apple-darwin13.4.0(64位) 运行于:OS X Yosemite 10.10.5 – Nicolas
@Nicolas:奇怪!我刚刚在Ubuntu中使用RStudio尝试过,并遇到同样的问题。我会更新这个问题。 –
您的替代解决方案也适用于我的Mac,谢谢! – Nicolas