Pyplot: Different scales for normalized colorbars

When visua­li­zing two-dimen­sio­nal data sets, cer­tain types of heat­maps are often useful. In many such cases, the­re is some reasonable „cen­ter“ of the color­map. For exam­p­le for a topo­gra­phic map indi­ca­ting ele­va­tions the sea level is often such a base­line. Howe­ver, moun­ta­ins often have a lar­ger ele­va­ti­on ran­ge than water has depth ran­ge. In such cases, it might be useful to use dif­fe­rent line­ar sca­les on both sides of the cen­ter value.

In this post, I’ll dis­cuss how to crea­te plots like the­se with Python’s Mat­plot­lib using code examp­les deri­ved from the Mat­plot­lib docu­men­ta­ti­on. In par­ti­cu­lar, I’ll com­ment on a weird ver­si­on-depen­dent beha­vi­or dif­fe­ring for Mat­plot­lib 3.4 and 3.5. wei­ter­le­sen…