A late night 🧵 on some tips for making grayscale (BW) & colorblind (cblind) friendly graphs in @Stata. BW in case people print out papers, and cblind to make sure documents are "barrier free".
Graphs have 3 elements that we can control: colors, line patterns, & symbols.
Let's start with colors: Whatever color scheme we use, we can check whether it will pass the BW and cblind tests. This can be easily tested using the palettes package. Install these, if you haven't already:
There are three types of common color-blindnesses that can we can check in #Stata: "Protanopia" & "Deuteranopia" where shades of red and green are not discernable, & "Tritanopia" where blue-green, purple-red, yellow-pink are hard to differentiate.
Test yourself 👇👇
3/
The extreme case is where one has both red-green & blue-yellow colorblindness.
Let's take the default s2 colors & see if it passes the test: The BW part has gray shades spaced out for the first 5 colors but spacing is not even. Same for cblind.
4/
There are several well thought-out color palettes readily available. For example, I use "tableau" a lot. Let, see how it does using the same code as above but just replacing s2 with tableau:
It sort of also works for grayscale and some of the cblind options but not all.
5/
Let's try 2 purpose built schemes: These are "okabe" and "viridis". Okabe is for discrete variables. You can see that it passes the cblind test very well but not the B&W one. But look at Viridis. You can see immediately what makes it so popular. It passes all the tests 🤩!
6/
Below r the results of the 4 cblind schemes I have released as part of the schemepack (github.com/asjadnaqvi/Sta…)
tab1, tab2, tab3, cblind1
They all work well for colorblindness, maybe not for all BW shades. Here we can add additional elements for more control.
7/
These are markers and lines. By default I do not build these inside my own schemes. They are controlled at a second stage. Let's see how:
Load the schemepack, data, and do a basic plot. Tableau colors are great for colored images but maybe they do not work well in BW.
8/
Let's pass a cblind friendly color scheme. Here Okabe gives us higher contrast in colors.
We can also select any other cblind scheme from the "colorpalettes" package and pass it.
We can also pass on custom line patterns using "linepalette" (also part of the palettes suite), where we can access sets of different patterns.
The command also allows us to pick the patterns we want using the "select" option. See its help file.
10/
Lastly, we can also customize the markers using the "symbolpalette". We can also pick & choose sets & select markers within them.
We can also combine all of the above 3 elements. Just need some pratice with storing & passing around locals. But this should be case-dependant!
11/
To summarize: colors, line patterns, & markers can be easily modified in #Stata to create BW & cblind friendly graphs. It might seem a lot of work, but one can generate a template of colors & patterns and save these, either in custom scheme files, or just as scripts.
12/
The #30DayMapChallenge 2022 starts tomorrow. In the last 2 years a lot of work has been put in @Stata to mainstream some of the map elements we find in other softwares. He is a 🧵 on the different types of maps one can make. If you want the code for any, just msg! Let's go 👇
The basic #spmap package can already do a lot! Here are some examples using standard spmap syntax.
These were made for the online #GIS tutorials earlier this year that were fairly well attended! Over 1400+ registrations and 500+ ppl online. Might repeat it again.
The #bimap package that actually was the result of the #30DayMapChallenge last year allows you to combine two variables to check for interesting spatial correlations.
1/ The #WorldBank's #SDG atlas covers each #SDG goal in detail with some great datavizzes inside each of them. Check it out! Really a lot of effort went into this.