Two or more sets of colour scales

65 views
Skip to first unread message

Roey Angel

unread,
May 17, 2012, 3:29:00 PM5/17/12
to ggp...@googlegroups.com
Hi,
I was wondering if there's a way to set two or more distinguished colour scales for one plot.
For instance, I'm trying to plot several time courses of different samples on one plot. I'd like the symbols of every time series to be in a smooth colour gradient but that each sample (each time series) to be distinguished from the others.
Ideally would be to be able to choose parts of one gradient but with breaks so that each sample gets a different part of the gradient.

Of course I'm aware of scale_colour_manual, but I'm trying to avoid that (too many samples and I wouldn't want to spend my time generating gradient, when others did a better job before me).

Suggestions are very appreciated
Roey

Brandon Hurr

unread,
May 17, 2012, 5:16:39 PM5/17/12
to Roey Angel, ggp...@googlegroups.com
I believe it is still the case that two color scales in one plot is still not possible. If you have faceted plots you could make two separate plots and put them together with grid.arrange(). 


Roey

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Roey Angel

unread,
May 20, 2012, 5:51:43 PM5/20/12
to ggp...@googlegroups.com, Roey Angel
Hi Brandon
Thanks for the quick reply.
Then, do you know of a way to extract n values from a colour gradient somehow? as in generating the first 20 values of any of the scale_gradient or scale_brewer?

Thanks again for the help
Roey

Brandon Hurr

unread,
May 21, 2012, 2:36:00 PM5/21/12
to Roey Angel, ggp...@googlegroups.com
This is certainly possible and I remember seeing it at some point when I was playing with the coloring system a year ago. I can't seem to find it though. Perhaps someone else will recall?

Brandon Hurr

unread,
May 27, 2012, 3:55:44 AM5/27/12
to Roey Angel, ggp...@googlegroups.com
Roey,

I don't think anyone answered your question in the end. Baptiste is
working on a blog post (or three) on working with color and ggplot.
The draft is currently here:
http://baptiste-auguie.tumblr.com/day/2012/05/26

B

baptiste auguie

unread,
May 28, 2012, 6:13:22 AM5/28/12
to Roey Angel, ggp...@googlegroups.com
On 21 May 2012 09:51, Roey Angel <an...@mpi-marburg.mpg.de> wrote:
> Hi Brandon
> Thanks for the quick reply.
> Then, do you know of a way to extract n values from a colour gradient
> somehow? as in generating the first 20 values of any of the scale_gradient
> or scale_brewer?

Something like this, probably:

scales::hue_pal(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0,
direction = 1)

scales::seq_gradient_pal(low = "#132B43", high = "#56B1F7", space = "Lab")

RColorBrewer::brewer.pal(8, "Set1")

HTH,

baptiste
>>> To unsubscribe: email ggplot2+u...@googlegroups.com
>>> More options: http://groups.google.com/group/ggplot2
>>
>>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com

Brandon Hurr

unread,
May 28, 2012, 8:39:00 AM5/28/12
to baptiste auguie, Roey Angel, ggp...@googlegroups.com
You need to add the number of outputs to the scales:: helpers.

?hue_pal
scales::hue_pal(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0,
direction = 1)(20)

?seq_gradient_pal
#and you have to supply a gradient to the gradient helper
x <- seq(0, 1, length = 25)
scales::seq_gradient_pal(low = "#132B43", high = "#56B1F7", space = "Lab")(x)

Very useful functions... thanks for pointing them out Baptiste.

Brandon

Roey Angel

unread,
May 31, 2012, 3:55:00 AM5/31/12
to ggp...@googlegroups.com
Thanks a lot Brandon and Baptiste!!
your codes work great and do exactly what I was looking for.

Thanks again
Roey
Reply all
Reply to author
Forward
0 new messages