27 Perception/Color Resources
27.1 Overview
This section has resources for learning about graphical perception and how to use colors effectively.
27.2 Perception
Here are some links to some key books/articles on perception:
- Graphical Perception: Theory, Experimentation, and Application to the Development of Graphical Methods: Classic article from William Cleveland and Robert McGill
- The Elements of Graphing Data: Textbook by William Cleveland
- Visualizing Data: Textbook by William Cleveland
- Creating More Effective Graphs: Textbook by Naomi Robbins
27.3 Color
Color is very subjective. It is important to choose the right ones so that your work is easy to understand.
- Color Brewer: Excellent resource for getting effective color palettes for different projects. Its main focus is on cartography, but it is super useful for any project involving color. You can choose between different types of data (sequential, diverging, qualitative), ensure your chosen palette is effective for colorblind users (or print friendly or photocopy safe), and easily export the color palette to different formats (Adobe, GIMP/Inkscape, JS, CSS). The best go-to for effective color palettes.
- Color Blindness Simulator: Not sure how effective your project will be to a colorblind user? This tool can help. You can upload an image to see how it will look with different color vision handicaps.
- ColorPick Eyedropper: This Chrome extension allows you to copy hex color values from webpages. Simple and intuitive, it will make creating your awesome color palettes a lot easier.
27.4 Quick tips on using color with ggplot2
One of the most common problems is confusing color
and fill
. geom_point()
and geom_line
use color
, many of the other geoms use fill
. Some use both, such as geom_tile()
in which case color
is the border color and fill
is the fill color.
27.4.1 Continuous data
27.4.1.1 ColorBrewer
scale_color_distiller(palette = "PuBu")
orscale_fill_distiller(palette = "PuBu")
(What doesn’t work: scale_color_brewer(palette = "PuBu")
)
27.4.1.2 Viridis
scale_color_viridis_c()
orscale_fill...
(the c stands for continuous)
27.4.1.3 Create your own
+ scale_color_gradient(low = "white", high = "red")
or + scale_fill...
+ scale_color_gradient2(low = "red", mid = "white", high = "blue", midpoint = 50)
or + scale_fill...
+ scale_color_gradientn(colours = c("red", "pink", "lightblue", "blue"))
or scale_fill...
27.4.2 Discrete data
27.4.2.1 ColorBrewer
scale_color_brewer(palette = "PuBu")
orscale_fill...
27.4.2.2 Viridis
scale_color_viridis_d()
orscale_fill...
(the d stands for discrete)
27.4.2.3 Create your own
+ scale_color_manual(values = c("red", "yellow", "blue"))
or scale_fill...
+ scale_fill_manual(values = c("red", "yellow", "blue"))
or scale_fill...
with