如何更改 ggplot 在 RStudio 中使用的默认颜色?

时间:2021-07-26 01:05:00

标签: r ggplot2

我收到了以下代码来生成绘图并在 R 中执行多重对应分析。

ACM_mp %>%
  rownames_to_column() %>%
  rename(Categoria = 1) %>%
  ggplot(aes(x = Dim.1, 
             y = Dim.2, 
             label = Categoria, 
             color = Variável, 
             shape = Variável)) +
  geom_point() +
  geom_label_repel() +
  geom_vline(aes(xintercept = 0), linetype = "dashed", color = "grey") +
  geom_hline(aes(yintercept = 0), linetype = "dashed", color = "grey") +
  labs(x = paste("Dimensão 1:", paste0(round(ACM$eig[1,2], 2), "%")),
       y = paste("Dimensão 2:", paste0(round(ACM$eig[2,2], 2), "%"))) +
  scale_color_viridis_d() +
  theme(panel.background = element_rect("white"),
        panel.border = element_rect("NA"),
        panel.grid = element_line("gray95"),
        legend.position = "none")

"ggplot" 函数使用列 "Variável" 来区分要绘制的项目,但使用很难看到的默认黄色。我相信这是 RStudio 的默认颜色。我的问题是如何通过更改 RStudio 的默认颜色或定义要使用的颜色向量来更改绘图上显示的颜色?

我曾尝试将“Variável”更改为“black”,但随后所有项目都已更改。这不是我想要的。

这是ggplot生成的默认图。

enter image description here

0 个答案:

没有答案
相关问题