Reverse rainbow color scale from scale_colour_gradientn

5,930 views
Skip to first unread message

Kevin Stierhoff

unread,
Jul 12, 2013, 12:25:02 AM7/12/13
to ggp...@googlegroups.com
I am trying to plot water temperature data, symbolized using scale_colour_gradientn(colours = rainbow(10)). The plot is perfect, except that the cool temperatures are red and warm temperatures are violet (opposite of what's intuitive). 

Is there an argument that will flip the colors, or is another palette that is better to use for temperature data?

baptiste auguie

unread,
Jul 12, 2013, 9:07:24 AM7/12/13
to Kevin Stierhoff, ggp...@googlegroups.com
colours = rev(rainbow(10)) ?

HTH,

b.

On 12 July 2013 01:25, Kevin Stierhoff <kevin.s...@gmail.com> wrote:
I am trying to plot water temperature data, symbolized using scale_colour_gradientn(colours = rainbow(10)). The plot is perfect, except that the cool temperatures are red and warm temperatures are violet (opposite of what's intuitive). 

Is there an argument that will flip the colors, or is another palette that is better to use for temperature data?

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nicole K.S. Barker

unread,
Jul 12, 2013, 12:56:56 PM7/12/13
to Kevin Stierhoff, ggp...@googlegroups.com
The rainbow palette is generally not recommended (e.g., http://www.research.ibm.com/people/l/lloydt/color/color.HTM). 

You can make your own colour palette using the colorRampPalette function: http://www.inside-r.org/r-doc/grDevices/colorRampPalette
Here are some example colour schemes http://geography.uoregon.edu/datagraphics/color_scales.htm.
RColorBrewer has some built in colour schemes you can use to create palettes: http://cran.r-project.org/web/packages/RColorBrewer/RColorBrewer.pdf

Nicole

Kevin Stierhoff - NOAA Federal

unread,
Jul 12, 2013, 3:47:26 PM7/12/13
to Nicole K.S. Barker, Kevin Stierhoff, ggp...@googlegroups.com
Thank you Nicole, for your response and for links to some very interesting articles on the topic. I learned to use colorRampPalette not long after my post, and got it to work for me. Since I am making exploratory plots of temperature in the range of 12-20C, I think the rainbow (or rev(rainbow), in this case) will suffice. I will, however, give more thought to colors that I choose!

Kevin
Kevin Stierhoff
Research Fisheries Biologist
NOAA Fisheries-SWFSC
8901 La Jolla Shores Dr.

Reply all
Reply to author
Forward
0 new messages