在matplotlib中定义颜色图的中点 [英] Defining the midpoint of a colormap in matplotlib

查看:57
本文介绍了在matplotlib中定义颜色图的中点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个色彩图的中间点,即我的数据从-5到10,我希望零成为中间点.我认为实现此目的的方法是归一化规范化并使用规范,但是我没有找到任何示例,而且我不清楚我到底要实现什么.

I want to set the middle point of a colormap, ie my data goes from -5 to 10, i want zero to be the middle. I think the way to do it is subclassing normalize and using the norm, but i didn't find any example and it is not clear to me, what exactly i have to implement.

推荐答案

请注意,在matplotlib版本3.1中,

Note that in matplotlib version 3.1 the DivergingNorm class was added. I think it covers your use-case. It can be used like this:

from matplotlib import colors
colors.DivergingNorm(vmin=-4000., vcenter=0., vmax=10000)

这篇关于在matplotlib中定义颜色图的中点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆