thekingzapper
thekingzapper

Reputation: 103

How can I give my own names to colours in R?

I've got a series of charts to plot, and I'd like to use the colours from my company's branding for all of them. I have the hexadecimals for each, but rather than writing those out for every plot, I'd like to use colours' names eg compplum, compyellow, compgreen etc. How can I set

compplum = "#6C217E"

at the beginning of my script, so that later on I can just write colour = "compplum" instead of colour = "#6C217E"?

Upvotes: 3

Views: 408

Answers (2)

Akagbusi Precious
Akagbusi Precious

Reputation: 1

There are several color palettes available in R such as rainbow(), heat.colors(), terrain.colors(), and topo.colors(). We can visualize these as 3D pie charts using the plotrix R package. so it depends the one u want to use

Upvotes: -1

alan ocallaghan
alan ocallaghan

Reputation: 3038

Why not use variables to hold the hex values?

mycompanycol <- "#0FF0F0"
plot(rnorm(100), rnorm(100), col = mycompanycol)

Upvotes: 6

Related Questions