R语言 控制ggplot2散点图中的多个图例元素

cygmwpex  于 2023-03-20  发布在  其他
关注(0)|答案(1)|浏览(180)

我想用ggplot稍微修改一下我在R中做的散点图的元素。

我想把IA表型改变成蓝色、黄色和红色元素的彩色圆圈,但中心是白色的。下面是我用来创建图表的代码。

t_chart2 <- ggplot(chart_data, aes(x = CD8.Density.Stroma.mm, y = CD8.Density.Tumor.mm, label = Sample)) +
  scale_x_log10()+
  scale_y_log10()+
  geom_point(aes(shape = Indication, 
             colour = IA.Phenotype, 
             fill = Pathologist.Phenotype), size = 3, stroke = 2) +
  scale_shape_manual(values = c(21, 22, 23, 24, 25)) +
  scale_color_manual(values = c("Blue", "Orange", "Red")) +
  scale_fill_manual(values = c("Blue", "Orange", "Red")) +
  theme_bw() +
  guides(fill = guide_legend(override.aes = list(shape =21)))
toe95027

toe950271#

我实际上自己想出了怎么做。我基本上只是加了一个颜色选项。

guides(fill = guide_legend(override.aes = list(shape =21, size = 4, colour = 'white')),
         colour = guide_legend(override.aes = list(shape = 21)))

相关问题