[英]Greek Letters for stat density 2d plot
Consider the following plot: 考虑以下情节:
# fake data
set.seed(1234)
n <- 200
gg <- data.frame(wf=rnorm(n,0.5),wb=rnorm(n,0.5),z=runif(n,0,6))
# plot it
gg$`My Title` <- gg$z
ggplot(data=gg, aes(x=wf, y=wb, color=`My Title`)) +
geom_point(aes(colour=z),shape="") +
stat_density2d(aes(fill = ..level..),n = 100,contour = TRUE,geom = "polygon") +
labs(x=expression(w[f]),y=expression(w[b])) +
guides(fill=F)
I would like to change My Title
to a greek letter or a mixture of text with greek letter. 我想将“ My Title
更改为希腊字母或文本与希腊字母的混合体。 Thanks! 谢谢!
Adding guides(colour=guide_colorbar(title=expression(paste("This is a greek letter: ", alpha))))
should work: 添加guides(colour=guide_colorbar(title=expression(paste("This is a greek letter: ", alpha))))
应该可以:
# fake data
set.seed(1234)
n <- 200
gg <- data.frame(wf=rnorm(n,0.5),wb=rnorm(n,0.5),z=runif(n,0,6))
ggplot(data=gg, aes(x=wf, y=wb, color=z)) +
geom_point(aes(colour=z),shape="") +
stat_density2d(aes(fill = ..level..),n = 100,contour = TRUE,geom = "polygon") +
labs(x=expression(w[f]),y=expression(w[b])) + guides(fill=F) +
guides(colour=guide_colorbar(title=expression(paste("This is a greek letter: ", alpha))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.