小编Reb*_*cca的帖子

如何在不均匀的色带处将 0 设置为白色

我的色带不均匀,我希望 0 为白色。所有负色必须是蓝色的,所有正色必须是红色的。我当前尝试显示 0 偏蓝色和 0.7 白色。

有没有办法将0设置为白色?

import numpy as np
import matplotlib.colors as colors 
from matplotlib import pyplot as m

bounds_min = np.arange(-2, 0, 0.1)
bounds_max = np.arange(0, 4.1, 0.1)
bounds = np.concatenate((bounds_min, bounds_max), axis=None)       
norm = colors.BoundaryNorm(boundaries=bounds, ncolors=256)      # I found this on the internet and thought this would solve my problem. But it doesn't...
m.pcolormesh(xx, yy, interpolated_grid_values, norm=norm, cmap='RdBu_r')
Run Code Online (Sandbox Code Playgroud)

python colors matplotlib colorbar matplotlib-basemap

4
推荐指数
1
解决办法
1万
查看次数