I wanted to create some visualizations to make the benefits of Dvorak and Colemak more apparent. Here are some heatmaps I generated in Python using numpy and Pillow. These are based on the frequency of letter usage (data from Wikipedia). Red corresponds to more frequently used areas, and blue corresponds to less frequently used areas.
QWERTY
Colemak
Dvorak
Pretty cool, huh? You can see that clearly, Colemak and Dvorak allow you to stay on the home row (the middle row) far more than QWERTY does. QWERTY just has your fingers going all over the place.
The math behind the heatmaps
I actually generated the pixel data for the heatmaps using my own algorithm, since I thought it would be fun. I don’t actually know how heatmaps are typically generated, but maybe it’s somewhat similar to this. I’ll explain the math I used.So here’s the information I started with:
- , the number of keys on the keyboard
- for , the pixel coordinates of key
- , the frequency of usage of key (i.e. the proportion of all letters that this letter makes up)
I needed a way for keys to color the points closer to them with a higher intensity than points farther away from them. For this, I used something similar to a Gaussian PDF. I used this formula to determine how much key should color point :
To break this down, the term represents the squared distance between the point to color and the key in question. When we multiply by -0.003 (a completely arbitrary constant that I fould worked well) and then exponentiate it, we get a term that peaks at , but then tapers off to 0 uniformly in all directions as it gets farther and farther from . Then we multiply it by , since we want more frequent keys to have more intensity than less frequent keys. I then summed these terms over all to get my final calculation:
This is what my program calculated for every point in the image. It then converted it to an appropriate RGB color, and saved the image as a PNG so that I could see it!
Written with StackEdit.