I would like to use two color palettes on the same plot. I have two groups and different modalities inside and my goal is each group has its own color palettes
i don t manage to do that with scale_colour_brewer
could anyone help me.
cheers
My topics is actually broad. I am going to specify.
I can sum up my data as follow :
| side | factor | Time | value |
|------|---------|------|-------|
| Left | methodA | 0 | 5 |
| Left | methodA | 1 | 3 |
| Left | methodA | 2 | 2 |
| Right| methodA | 2 | 2 |
| Right| methodA | 2 | 2 |
| Right| methodA | 2 | 2 |
| Left | methodB | 0 | 5 |
| Left | methodB | 1 | 3 |
| Left | methodB | 2 | 2 |
| Right| methodB | 2 | 2 |
| Right| methodB | 2 | 2 |
| Right| methodB | 2 | 2 |
i would like to plot a line of Value against Time - use a red color palette for Side == Left with factor represented by a red variation - use a blue color palette for Side == Right with factor represented by a blue variation
cheers
Note: the suggested approaches below are feasible when the number of factors within each group is reasonably small. If there are many different group-factor combinations, your audience may not be able to tell the difference between small changes in colour, in which case faceting by group could allow for a clearer & cleaner picture.
(My own working assumption for any presentation is to assume that the projector is >10 years old, the printer ran out of ink, & at least half the target audience are overdue for new prescription lenses...)
Approach 1: vary
colour
by group & varyalpha
by factorThis works best when the lines do not overlap too much, since the overlapped regions look darker.
Approach 2: (for 2 factors only) create a combined variable & use "Paired" palette
RColorBrewer
package's "Paired" palette has 12 colours in (roughly) 6 pairs. If you have <=6 groups & 2 factors in each group, this could be a easy way to assign the colours. Here's a colour wheel for reference: