Skip to content
Uncertainty visualisation in maps: Display measurement value and error simultaneously with Python/matplotlib
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.txt
README.rst
cam-CAM.png
cam-JCh.png
demo_colorspace.png
demo_colorspace_gray.png
demo_observation_RdBu.png
demo_observation_cool.png
demo_observation_coolwarm.png
demo_observation_error.png
demo_observation_plasma.png
demo_observation_spring.png
demo_observation_summer.png
demo_observation_value.png
demo_observation_viridis.png
demo_observation_winter.png
test.py
testcam.py
testcmaps.py
testlab.py
testluma.py
uncertaincolors.py

README.rst

Maps with Measurement Uncertainty

This is an attempt at implementing uncertainty Visualisation with matplotlib. I want to show measured value and uncertainty in the same image, like here:

http://spatial-analyst.net/wiki/images/thumb/3/32/Fig_comparison_visualisation.jpg/450px-Fig_comparison_visualisation.jpg

(their website is informative: http://spatial-analyst.net/wiki/index.php?title=Uncertainty_visualization )

Examples

Lets say we have this observation:

https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_value.png

And the uncertainty increases from center to outside:

https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_error.png

Here are some attempts:

  1. This whitens with increasing error:

    https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_spring.png
  2. Cool color map:

    https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_cool.png
  3. This one grays out:

    https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_plasma.png
  4. With viridis color map:

    https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_viridis.png
  5. Winter:

    https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_winter.png
  6. Some color maps do not work well, like Red-Blue. This is because the middle is too bright.

https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_observation_RdBu.png

Approach

There are two axes: value is mapped to hue/color, and error should modify either lightness or saturation.

Modern colormaps are perceptually uniform. They increase the lightness/luma in lockstep with the color.

Here however we two independent axes, like here:

https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_colorspace.png

On the vertical axis are different colors. Towards the right, the image desaturates (with increasing uncertainty).

The nice thing about this approach is that in a black-and-white print-out, only one axis is lost (saturation), but the vertical axis (lightness) still goes with value.

Here is the same image, grayscaled:

https://raw.githubusercontent.com/JohannesBuchner/uncertaincolors/master/demo_colorspace_gray.png

Code

Code can be found in https://github.com/JohannesBuchner/uncertaincolors/blob/master/uncertaincolors.py

Why not just map with HSV?

Initially I thought to just go to a colorspace such as JCh or HSV that have color (Hue H) and lightness or saturation as independent axes (V,J). This gives images like this one:

JCh

CAM02-UCS

The arcs make the image useless. Colors here are not desaturized homogeneously.

Instead, the approach I chose is to select a colormap and get the initial values (at uncertainty 0) and find their saturation. I normalise the colormaps to the same saturation. The second axis then desaturates until no color is left.

You can’t perform that action at this time.