【问题标题】:Greek Letters for stat density 2d plot统计密度二维图的希腊字母
【发布时间】:2016-01-13 12:41:14
【问题描述】:

考虑以下情节:

# 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)

我想将My Title 更改为希腊字母或文本与希腊字母的混合体。 谢谢!

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    添加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))))
    

    【讨论】:

      猜你喜欢
      • 2021-07-16
      • 2021-07-02
      • 2014-11-02
      • 1970-01-01
      • 2013-12-25
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多