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