ggplot2 中的图例标题

hol*_*lly 1 r ggplot2

我正在努力更改 ggpplot2 中的图例标题。该情节的图例标题为“Enrichment_Score”,我想更改为“Enrichment Score”。

如果有人能提供建议那就太好了。

D1 <- ggplot(Practice, aes(Practice$case, Practice$pathway, 
      colour = Enrichment_score, size = Practice$q.value)) +
  geom_point() +
  scale_colour_gradientn(colours = cols) +
  theme(legend.position="bottom") +
  scale_size(range = c(1,15)) +
  guides(size=guide_legend(title = "FDR q value"),
         scale_color_gradient=guide_legend("Enrichment Score"))

 
D1 + ggtitle("Gene Set Enrichment Treg cells") +
  xlab("Case") + ylab("Hallmark Gene Sets") +
  theme_bw() ```

Run Code Online (Sandbox Code Playgroud)

Treg细胞

小智 5

您可以通过 ggplot2 函数重命名图例中的美学,labs如以下 reprex 所示。

library(ggplot2)

df <- data.frame(
  x = runif(100),
  y = runif(100),
  z1 = rnorm(100),
  z2 = abs(rnorm(100))
)

ggplot(df, aes(x, y)) +
  geom_point(aes(colour = z1)) +
  scale_colour_gradient2() +
  labs(colour = "My Legend Name")
Run Code Online (Sandbox Code Playgroud)

代表输出

由reprex 包于 2021 年 10 月 13 日创建(v2.0.1)