[R] ggplot2 recycle color palette

Jim Lemon drjimlemon at gmail.com
Wed Mar 18 10:05:03 CET 2015


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:

> 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")
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list