RColorBrewer Package
display.brewer.all(n,type,colorblindFriendly)
Input:
- n - number of colors you want
- type - type of data (qual for qualitative,seq for
sequential,or div for diverging)
- colorblindFriendly - TRUE or FALSE (set TRUE to
return color blind friendly colors)
Output:
- Visual representation of available colors. Each set has a name,
which can be called in code.
display.brewer.all(n=5,type='div',colorblindFriendly=TRUE)

brewer.pal(n,name)
Input:
- n - number of colors you want
- name - name of color palette, which can be found
using display.brewer.all()
Output:
## [1] "#7FC97F" "#BEAED4" "#FDC086" "#FFFF99" "#386CB0"
Qualitative Data
Color Blind Friendly Options
display.brewer.all(n=NULL,type='qual', colorblindFriendly=TRUE)

Graph
ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) +
geom_bar( ) +
scale_fill_brewer(palette = "Dark2") +
theme(legend.position="none")

Sequential Example
Color Blind Friendly Options
display.brewer.all(n=NULL,type='seq',colorblindFriendly=TRUE)

Graph
ggplot(data = midwest, aes(x = area, y = poptotal)) +
geom_point(aes(col=state, size=popdensity)) +
ggtitle("Area Vs Population") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_color_brewer(palette='YlOrRd')
