How to set number of value ranges in colorbar?
29 次查看(过去 30 天)
显示 更早的评论
Hello everyone, i wanna ask, how to set number of value ranges is equal with number of color grading in colorbar?
Color grading have 14 colors, but the value just 10. Thank you
1 个评论
Walter Roberson
2022-8-6
I do not seem to be able to replicate that when I activate a colormap that I have set a specific size for.
cmap = flag(10);
colormap(cmap);
colorbar()
回答(1 个)
Cris LaPierre
2022-8-6
Use the 'tick' property to specify tick locations. See this related answer: https://www.mathworks.com/matlabcentral/answers/447758-how-place-the-tick-at-the-mid-value-of-specific-color-range-and-uniform-color-bar-across-different-r
% Create data & plot
data = peaks(25);
contourf(data)
cmap = jet(14);
colormap(cmap);
% Specify tick locations in colorbar automatically
cl = clim;
ct = linspace(cl(1),cl(2),size(cmap,1)+1);
c=colorbar('Ticks',ct);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!