Having trouble picking a color palette for your #Rstats visualization? Well here's a MEGA thread about all the ways you can choose a palette! 🧵[1/22]
We'll start off with the classics. First, you can use the palettes that are already a part of R's base code (keep in mind that these palettes were not necessarily designed to be colorblind-friendly)
[2/22]
The next classic set of palettes comes from {RColorBrewer}. You can use the command display.brewer.all(colorblindFriendly = TRUE) to see which palettes are colorblind-friendly.
Now onto some lesser-known packages. This one is starting to gain popularity in the community: {wesanderson}. This package has a variety of palettes inspired by Wes Anderson films which are all colorblind-friendly.
Another package which was inspired by the wesanderson package is {ghibli} which has palettes inspired by Studio Ghibli movies which are also all colorblind-friendly. PonyoMedium is one of my favorites!
The package {ggsci} contains color palettes inspired by colors used in scientific journals (FYI, these palettes may not be the best choice when trying to create visualizations that are colorblind/printer/photocopy-friendly)
The Python package 'seaborn' has some great color palettes, including a color-blind friendly one. You can load these colors in manually using this R code from GitHub: github.com/timelyportfoli…
[9/22]
None of these preset palettes tickle your fancy? Make your own! There are a variety of packages and websites that can help you do this.
(Pictured: example of a visualization I made with a custom color theme)
[10/22]
If you don't want to use HEX codes, R has 657 built-in color names. See this cheatsheet for more information: nceas.ucsb.edu/sites/default/…
[11/22]
Generate some random colors using the package {randomcoloR} where you can specify things like hue and brightness. Here are a couple examples: hue="red" and luminosity="light"
Making an elevation map and want it to look like the actual place it's from? Use the package {earthtones} to derive a color palette from a particular location on Earth
Use the package {qualpalR} which, when given a number of colors (n) and an HSL color space, provides n colors which maximize smallest pairwise color differences.
Another really interesting/cool way to build a custom color palette is to generate one from an image, which you can do thanks to the package {paletteR}
You can also create a palette on the website Data Color Picker (link: learnui.design/tools/data-col…) which generates palettes for you with lots of options, including viewing the palette on a dark background, and selecting a single-hue or divergent palette.
[18/22]
REGARDLESS of which method you use, please keep the colorblind community in mind. There are numerous tools out there to test whether your color palette is colorblind-friendly, I'll provide a couple that I use.
Found a really interesting survey, went to look at the results and the charts were physically painful to look at. So many #dataviz violations 😩 Here are some things I noted that should’ve been avoided:
A thread 🧵 (1/16)
1. PIE CHARTS - Unlike most data viz experts, I don’t completely *hate* pie charts. However, I think they should be used very sparingly and only when 2-3 categories are being represented.
(2/16)
2. TOO MUCH COLOR - Each bar of a bar chart doesn’t need to be a different color. Besides the undesirable “rainbow effect”, it’s distracting and unnecessary. We know each bar represents a different category because they are labeled, so the extra encoding is not needed.
Sick and tired of the default R fonts? Here’s a comprehensive guide to using different fonts in ggplot2!
🧵 THREAD [1/15]
STEP 1: Find a font. There are many places to find fonts such as fontspace.com and fonts.google.com (which is what I use). Regardless of where you get your font, make sure you download it as a TrueType Font (.ttf) file!
[2/15]
STEP 2: Picking a font. It is best practice to use fonts that are legible as well as dyslexic-friendly. You can accomplish this by using Sans Serif fonts.