How to split values into binned categories for regions and points
In our map templates, when you have a categorical column in your dataset, you can adjust your palette to customize the coloring of your regions or points. On the other hand, when shading numerically, there are lots of options to customize the scale, the colors used, and the map legend.
In this help doc you will learn how to add custom bins to your data to customize the legend and colors of your choropleth maps, as well as to color your point maps numerically. This is useful for when you want to split your data by specific ranges that may not be available through our custom thresholds options or for when you want to map your values to customized categories. Keep reading to learn how to do this.
In this article
How to make custom bins with your data
In this example, we're demonstrating with Google Sheets, but Microsoft Excel has equivalent functions.
- 1
- Create a Google Sheet and import your data.
-
-
- 2
- Separate from the main data, create a lookup style table that outlines the bins you want to create.
-
It should have two columns:
- one containing the minimum value of each bin (the maximum is taken from the next bin up)
- one containing the name of the bin as you want it to display in your legend.
-
NOTE: Choose your bin values carefully. Uneven or skewed bins can be misleading and can cause particular values to be disproportionately emphasised.
-
- 3
- Add a new column to your main data that will contain your bin categories.
-
- 4
- Create a VLOOKUP function taking the follow form:
-
=VLOOKUP(numeric_value, lookup_table, bin_name_column_index)
- In this example, this reads:
-
=VLOOKUP(D2,$G$2:$H$8,2)
-
TIP: Remember to preserve the cell references for your lookup table using
$
like in the example above. - 5
- Download your data, merge it into your Flourish map, and bind your bin category column to the Color by binding in the Regions tab.
- 6
-
Since we're using a
categorical color mode, the default colors of your palette might not be suitable for your map. You can change them by either selecting a new color palette, creating your own palette or using color overrides.
Read our help doc to learn how to do this.
-
-
NOTE: Remember we're using categorical values. This means that the number formatting options, like dividing values or adding suffixes, won't be available for you to use. You can use Google sheets or other spreadsheet programs to edit your data.
How to use custom bins with your regions
With the "Projection map" template you can color your regions categorically or numerically. Using custom binned values will allow you to further customize your legend.
- 1
- To your spreadsheet, add a column with the binned values following the steps outlined here and upload your data to Flourish.
- 2
- On the Data tab, bind the column with the binned values to the Colour category setting.
- 3
-
Sort the legend under
Legend > Custom order override, by entering the names of your bin categories, each on their own line and in the order they should appear in the legend.
How to use custom bins with your points
Unlike regions, points cannot be colored numerically in the “Projection map” template , only categorically. This means that, if you try to add a column with numeric values to the Colour category binding — which connects to the color options —, the template will assign a different hue to each unique value, rather than assigning hues based on a scale.
This can be problematic if you want to color your circles or spikes numerically, but you can bypass this problem by following these steps:
- 1
- To your spreadsheet, add a column with the binned values following the steps outlined in the previous section and upload your data to Flourish.
- 2
-
On the
Data tab, bind the column with the binned values to the
Color by setting under
Points. See the difference between the original data and the binned values.
- 3
-
Now that the data is in a format that the template can interpret, you can make further edits to your chart to make it look even better. You can edit your color palette and legend, using
color overrides.
TIP: You can use ColorBrewer, a free tool that helps you create map-specific color palettes.
- 4
- As an extra step, if you want your legend to be displayed in a band instead of separate swatches, follow the steps in this help doc to create a "fake" legend using HTML.