How can I create a normalized distribution for producing an hsl color array?

I am creating a heatmap, where paths of countries in an SVG get fill colors that are all a shade of red using HSL.

colorC = "hsl(0,100%," + colorL + "%)"

The map is working great by several different methods where the user selects his own color intensity manually, but I am wanting to improve the map by adding an "auto" feature that chooses a good color intensity based on the values of the dataset.

I have been playing with bell distributions and various forms of data normalization, but these are not really accomplishing the goal. Here is a little more about the working method.

There are two datasets that I have to deal with, a master dataset for all entries, which shows a strong skew toward the UK, and a target subset which I am trying to map. In my working method, I loop through the target subset, normalizing each countries data by the master dataset, multiplying each value by this manually selected colorIntensity.

colorL = (100 - (100 * colorIntensity * countrySubset[i] / countryMasterset[i]))

The default value is colorIntensity = 1, which works great for large subsets, but leaves everything largely whited out on smaller subsets. Subset size changes a lot, and as subsets are nested and can be walked up or down via parents and children, an automatic colorIntensity value would be a great asset.

So, here is the statistics question that is beyond my abilities. What type of normalization and/or distribution can help me show a nice distribution of colors that are never black hsl(0,100%,0%) and never white hsl(0,100%,100%), but nicely distributed somewhere in the deep red hsl(0,100%,25%) to light pink hsl(0,100%,99%) range? All zero values default to light gray.

For example, the following subset looks great at colorIntensity = 20 (USA data is used for the math, but not displayed on the map, as the map only shows Europe):

{ "Wales": 15, "USA": 11, "Netherlands": 1, "Ireland": 2, "England": 2 }

While this next subset looks much better at colorIntensity = 10 (this is a ggparent of the above):

{ "Germany": 34, "Switzerland": 12, "England": 44, "France": 13, "Italy": 10, "Sweden": 1, "Poland": 1, "Wales": 25, "USA": 44, "Canada": 3, "Mexico": 1, "Austria": 1, "Belgium": 1, "Ukraine": 1, "Portugal": 1, "Netherlands": 1, "Ireland": 20, "Denmark": 1, "Czech Republic": 8, "Luxembourg": 1, "Russia": 1, "Northern Ireland": 5, "Scotland": 29, "Turkey": 1, "Spain": 1, "Finland": 4 }

204 thoughts on “How can I create a normalized distribution for producing an hsl color array?”

  1. Pingback: stromectol dental
  2. Pingback: clamoxyl deltasone
  3. Pingback: ivermectin pills
  4. Pingback: 1 viagra
  5. Pingback: otc generic viagra

Leave a Comment