Create a custom color palette in R

Viewed 27675

I know that R is loaded with some color palettes automatically, such as palette, rainbow , heat.colors and gray. I'm also aware of RColorBrewer. But, what if I want to use a custom color palette and assign colors by name? Is that possible?

My company's color palette is as follows:

#1A73BA (R: 26 G: 115 B: 186) - this is a blue
#FFDB43 (R:255 G:219 B:67) - this is a yellow
#B54B05 (R:181 G:75 B:5) - this is an orange

My company's initials are AT.

I'd like to be able to call those colors via a name rather than by the HEX or RGB because I don't remember them. Ideally, I could create a file that would load into R automatically that would initiate these colors.

ATBlue <- #1A73BA
ATYellow <- #FFDB43
ATOrange <- #B54B05

Then, I could call the colors:

plot(x,y, col = "ATBlue")

I could put the values into a dataframe, then call them like so:

ATColors <- data.frame(name = c("ATBlue", "ATYellow", "ATOrange"), color= c("#1A73BA", "#F7D364", "#B54B05"))

plot(x,y, col = ATColors[3,2])

But I would need to know the location in the dataframe in order to call it correctly.

Can I create an element that will automatically load when R launches that would allow me call a custom color name into a plot?

3 Answers
Related