colormap I need have the color of the 0 explicit
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to make a colormap where i need the value of 0 is a different color of the rest i want it to be grey [0.5 0.5 0.5] taking into account the values I impose for the color bar
I need to take into account the clev
figure(1);
axis equal;
clev = -0.5:0.01:0.5;
[x,y] = meshgrid(lon,lat);
contourf(x, y, lwe', clev, 'LineStyle', 'none', 'Fill', 'on');
xlabel('Longitude');
ylabel('Latitude');
clim([min(clev), max(clev)]);
colormap(winter(length(clev)-1));
colorbar('eastoutside');
c = colorbar;
c.Label.String = 'Valor em metros (m)';
title(strcat('GRACE-', tm));
1 Kommentar
Dyuman Joshi
am 12 Sep. 2023
Bearbeitet: Dyuman Joshi
am 12 Sep. 2023
You can do that via the Colormap editor.
Or experiment with this FEX submission - https://in.mathworks.com/matlabcentral/fileexchange/110190-positive-zero-negative-colorbar
Antworten (1)
Walter Roberson
am 12 Sep. 2023
This cannot be done through colormap.
Colormaps use slots of equal width. The color stored in a slot is not required to be unique. It would be perfectly valid, for example, to create a colormap of 101 entries in which the top 50 and the bottom 50 were all the same color and the middle was a different color. But the middle would still occupy a range of values -- with a large-enough color map it might not be a big range of values, but it will never be a single value such as exactly 0 (with, for example, 1e-20 being the next color)
That said, if you happen to have a situation where the values are quantized, and the levels are symmetric, then you can do things such as
nlev = length(clev);
cmap = winter(nlev);
cmap((nlev+1)/2,:) = [0.5 0.5 0.5];
colormap(cmap);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Orange finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!