Color Coding Colleges
1. Color Coding Colleges
In the previous section, we colored our points to style the map. Now we will work to add both style and information to our map using color.2. Adding Color (and Information)
For example, this map of the colleges in Oregon uses the default blue circle markers. These markers reveal that Oregon's colleges are clustered in Portland and around the northern half of interstate 5. There are only four colleges scattered throughout the rest of the state. Color coding the markers by sector reveals that these four colleges are all the same sector. Do you think the colleges are public, private, or for-profit?3. Remembering your Colors
Adding a legend to our map, tells us that these outlying colleges are public institutions. It's often the case that when there is a college in rural America, it's a public institution. Perhaps more telling are the vast areas of Oregon that do not have a four-year college or university at all.4. colorFactor()
Let's take a look at the code that colored Oregon's colleges by sector. First, we create a data frame that contains only colleges in Oregon. Then, we use the colorFactor() function to build a color palette that connects our colors to the levels in the sector variable. Then we pass this palette to the color argument of addCircleMarkers(). Lastly, we add a legend using the addLegend() function so that we can remember what the colors represent.5. colorNumeric()
If we want to color points by a continuous variable instead of a factor, we can use the colorNumeric() function. For example, let's build a map of every college in America that admitted half or fewer of its applicants in 2016. First, we create our data that excludes colleges with admit rates of 50 percent or higher and colleges that did not admit anyone. Then we make our palette using a red color gradient that has a domain that matches the range of admit rates in our data. Setting reverse to true will flip the gradient, so smaller values are represented by darker shades of red. This will make more selective colleges easier to spot on our map. Lastly, we add a legend. Let's take a look at where America's most selective colleges are located.6. colorNumeric()
We are down to 346 colleges from more than 3,000. Only 11% of colleges in our admit data admit less than half of their applicants. Furthermore, the number of lightly colored institutions on our map appear to outnumber the darker markers, indicating that only a few colleges admit less than 20 percent of their applicants.7. Picking a Color Palette
Designing color palettes can be hard. I tend to rely on the RColorBrewer package that contains many well-designed color palettes that work well for maps. The color brewer website allows you to quickly navigate and test the available palettes to determine which will work best for your map.8. Let's practice!
Now it's your turn to build a color palette for the IPEDS data.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.