0

I have made a colour scale to clearly represent the data I am using. However, I now need to extract the colour code in Hex or RGB? How do I do this?

A reproducible example of the colour scale I have used is shown below.

library(ggplot2)
data.frame(x = c(1,1.5,2,5,10,20,30,50), y = 1:8) %>%
ggplot(aes(x= as.factor(x), y, colour = x)) +
geom_point() +
scale_colour_gradientn(colors = c("red",   "limegreen"),
                      trans = "log",
                      values = scales::rescale((c(0, 6, 7, 20, 50)))) 

enter image description here

The reason I need the colour codes is that I want to add a new colour/s which is unrelated to the scale used e.g also add in Blue and White.

Andre Elrico
  • 10,956
  • 6
  • 50
  • 69
Jonno Bourne
  • 1,931
  • 1
  • 22
  • 45

0 Answers0