0

I'd like to change the elements of a scatterplot I'm making in R using ggplot a little bit.

Chart

I'd like to change the IA phenotype to colored circles with the blue, yellow, and red elements coloring them, but a white center. Here's the code I used to create the chart.

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)))
fgootkind
  • 73
  • 6
  • 2
    Try adding `color = guide_legend(override.aes = list(shape = 1))` to the `guides` function. – mfg3z0 Mar 10 '23 at 04:30
  • 2
    It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. Also: Do you want to change the "legend" as you question suggests or do you also want to change how IA phenotype in displayed in your chart? – stefan Mar 10 '23 at 05:49

1 Answers1

0

I actually figured out how to do this on my own. I basically just added a colour option.

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