Creating attractive color schemes

You saw how to use scale_color_brewer to create various color schemes, starting with a range of blues (the default color scheme). While using this function, you must select the palette you wish to use. The scale_color_brewer() function uses syntax like this:

scale_color_brewer(..., type =  , palette = )

You can select either seq (sequential), div (diverging), or qual (qualitative). Within those options, you can then select a particular palette, where the available palettes control color schemes. Further information on scale_color_brewer() can be found at http://docs.ggplot2.org/current/scale_brewer.html.

Try all of the following lines of syntax yourself:

 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(type="div") 

 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(palette="Greens") 

 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(type="seq", palette=3) 

 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(type="seq", palette=4) 

 P + geom_point(aes(color = factor(ETH)), size=I(4)) +  scale_color_brewer(type="seq", palette=6) 
 
 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(type="seq", palette=7) 

 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(palette="Reds") 

 P + geom_point(aes(color = factor(ETH)), size=I(4)) + scale_color_brewer(palette="Set1")

You can devise many other combinations of type and palette. Let's see the graph of the last command:

Creating attractive color schemes

We have mapped attractive colors to each level of ethnicity.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset