-1

I havehttps://i.stack.imgur.com/JRm2K.png a plot in R which produced with ggplot2, I want to change the color from the left side to the right side,https://i.stack.imgur.com/mOYVj.png. how can I change the color to a blue pallete? thank you

Samin Ba
  • 13
  • 5
  • 3
    Please see [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). You can provide your data via the output of `dput(df)` or to give a minimal subset use `dput(head(df))`. – AndrewGB Jan 11 '22 at 07:15
  • 1
    One difference between the actual plot and the wanted plot is that injSeverity is a factor and not a number. When using factors there is a discontinuous color palette chosen by default in ggplot2. If you can provide a reproducible example, as @Andrew Gillreath-Brown suggested already, I could work further on that issue. This means. 1) please provide an example of the data 2) please provide your code for plotting. It is more likely to get a helpful answer when the question is nicely (-> clear and reproducible) asked. – JKupzig Jan 11 '22 at 08:29

2 Answers2

0

I think you need to use a palette. Lots of examples here - one of which should suit your needs - https://www.sthda.com/english/wiki/ggplot2-colors-how-to-change-colors-automatically-and-manually

strangecharm
  • 186
  • 11
0

Like the first comment on your question says it is a bit hard to help without any data and/or code example. Based on the question the best answer would probably be scale_fill_manual(). your boxplot code = bp

bp + scale_fill_manual(values=c("#999999", "#999999", "#999999", "#999999", "#999999", "#999999"))

Use a hexidecimal color map to find the colors you want and replace the 9's with the hexidecimal code you want.

Omniswitcher
  • 368
  • 3
  • 13