Introduction

This code through explores the package RColorBrewer which is very helpful when it comes to choosing colors for your graphs.


Content Overview

Specifically, we’ll explain and demonstrate how to use this package to pick colors for any graphic that you’re making and any audience who’s going to view it.


Why You Should Care

This topic is valuable because it can often be challenging to know which colors will look good together. This package offers premade pallets that you can pick between based on your data type. For example, the pallets are sorted in a useful way. The top ones are best to use for sequential items. The middle are for qualitative items. The bottom ones are for things that are “diverging” or very extreme. Which type you want to see can be specified in the code.


Learning Objectives

Specifically, you’ll learn how to use this package and create better/more visually appealing graphics.



Body Title

Here, we’ll show the very basics of this package. How to call all of the pallets at once to decide which one you’d like to use.


Further Exposition

This is based on the work of Cynthia Brewer, the creator of this package.


Basic Example

A basic example shows how all pallets can be called at once.


Advanced Examples

More specifically, this can be used for specific types of data, as mentioned above. If you only want to see a pallet for one type of data, sequential perhaps, you could call only those pallets using the below code.


What’s more, it can also be used for data that is purely qualitative - things that cannot be ranked on a scale.


Most notably, it’s valuable for ensuring that your graphics are accessible to all. There is an option to return only the pallets that are colorblind friendly. You can further subdivide this by specifying certain types of data or certain pallets.

Here is an example of this package in use. I used the cars data that comes preloaded in R and used col = brewer.pal with the number specifying how many different colors I wanted and the “Pastel1” representing which pallet I wanted to use. While I demonstarted with a histogram, I could’ve used other types of graphs by replacing hist with them. As you can see, the colors of the graph are very nice! I really like this package!



Further Resources

Learn more about [RColorBrewer] with the following:




Works Cited

This code through references and cites the following sources: