Skip to content

ggplot2 recycle color palette

2 messages · Glenn Schultz, Jim Lemon

#
Hello All,?

I have a custom color palette as illustrated below. ? I have more than 8 variables. ?In the case of more than 8 variables I would simply like to recycle the color. ?Has anyone done this or know of a way to have to colors recycle if there are more than 8 variables.

Best Regards,
Glenn
cbbPalette <- c("#E69F00",?
? ? ? ? ? ? ? ? "#56B4E9",?
? ? ? ? ? ? ? ? "#009E73",?
? ? ? ? ? ? ? ? "#F0E442",?
? ? ? ? ? ? ? ? "#0072B2",?
? ? ? ? ? ? ? ? "#D55E00",?
? ? ? ? ? ? ? ? "#CC79A7",?
? ? ? ? ? ? ? ? "#000000")
#
Hi Glenn,
An easy way is to replicate the colors to the correct length yourself. If
the number of variables is "nvar", then

newPalette<-rep(cbbPalette,length.out=nvar)

Jim

On Wed, Mar 18, 2015 at 12:07 PM, Glenn Schultz <glennmschultz at me.com>
wrote: