Stefano Potter
Stefano Potter

Reputation: 3577

Print out colors used in a color ramp?

I want to manually manipulate the colors I plot by from a color ramp. So right now I am using a code like this:

library(colorRamps)

plot(object, col = blue2red(10))

I want to be able to manually change one color in this color ramp sequence though. Is there a way to return the 10 colors being used in this ramp, and then edit just one of them?

Upvotes: 0

Views: 293

Answers (1)

Raad
Raad

Reputation: 2715

cols <- blue2red(10) # store colors in object
cols[2] <- "black" # change second element to black
barplot(rep(1, length(cols)), names.arg = cols, col = cols)

Upvotes: 1

Related Questions