matplotlib.colors.DivergingNorm
--Logscale: matplotlib.colors.LogNorm
matplotlib.colors.SymLogNorm
--In this case, the reference point will shift unless vmin == vmax is set.import numpy as np
import matplotlib.pyplot as plt
np.random.seed( 1 )
arr = np.random.uniform( -20.0, 100.0, (3,4) )
plt.imshow( arr, cmap='bwr' )
plt.colorbar()
Match 0 and white (reference point of color map) in the figure of
matplotlib.colors.DivergingNorm
matplotlib: matplotlib.colors.DivergingNorm
norm = mcolors.DivergingNorm( vcenter=0.0, vmin=-20.0, vmax=100.0 )
plt.imshow( arr, cmap='bwr', norm=norm )
matplotlib.colors.SymLogNorm
matplotlib: matplotlib.colors.SymLogNorm
norm = mcolors.SymLogNorm( linthresh=1.0, linscale=1.0, vmin=-100.0, vmax=100.0 )
plt.imshow( arr, cmap='bwr', norm=norm )
However, if vmin = -20.0
, the white position shifts from 0 (note the color bar in the figure below):
→ If you are particular about vmin = -20.0
, do you need to draw the array in two steps, + and-?
stackoverflow: Defining the midpoint of a colormap in matplotlib
Recommended Posts