I would like to change the colormap in my plot, from yellow to blue, to be from blue to white;only two colors with gradient. Is it possible?
Code:
x = randn(1000,1);
y = randn(1000,1);
[N,Xedges,Yedges] = histcounts2(x,y);
contourf(N)
any help is more than welcome.
You can specify the colormap to be used in the figure with the
colormap
function. A colormap is just a three-column matrix with values between0
and1
representing R,G,B components, so you can create it manually. For example, to produce a simple colormap from blue to white:However, this colormap is not perceptually uniform, that is, the perceived "color difference" is not uniform across the full color range. To generate a perceptually uniform colormap from blue to white I suggest the user-contributed
BrewerMap
function with the'Blues'
option: