【问题标题】:Changing colour of legend text same as mentioned colour of geom_point() using ggplot2使用 ggplot2 更改图例文本的颜色与提到的 geom_point() 的颜色相同
【发布时间】:2012-07-13 01:03:56
【问题描述】:

我的传说具有三个值,即高低中。

我希望文本 high 的颜色与形状对象相同,即蓝色和低为红色, 医学为绿色 geom_point() 中提到了颜色。

是否可以更改图例文本的颜色?

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    如果 p 是您的绘图,您可以将其保存为 grob 并使用网格命令逐一编辑标签,

    g = ggplotGrob(p)
    grid.draw(g)
    grid.edit("label-3", grep=TRUE, global=TRUE,
               gp=gpar(col="red", cex=1))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-27
      • 2023-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-21
      相关资源
      最近更新 更多