How to assign the color intervals while using the jet color chart?

8 ビュー (過去 30 日間)
Niraj Bal Tamang
Niraj Bal Tamang 2022 年 5 月 6 日
回答済み: Voss 2022 年 5 月 7 日
Can anyone please tell me how to increase the intervals betwwen the selected colors from a color chart (eg. jet or parula)? I used jet color chart to plot 16 data values but the selected colors look similar and hard to distinguish in the group plot. Can I change the shades of colors used so that they can have more distinguished colors?
x=[1 2 1 4 6 8 4 7 9 4 7 3 1 6 7 4];
y=[0.5 0.1 0.8 0.2 0.1 0.7 0.8 0.3 0.5 0.1 0.8 0.2 0.1 0.7 0.8 0.3];
c=jet(16); %Can we modify the interval between these 16 selected colors in the chart?

採用された回答

Voss
Voss 2022 年 5 月 7 日
If, by "modify the interval between" colors, you mean "use different" colors, then yes. You can use Any Colour(s) You Like. Perhaps a different built-in colormap like colorcube would be better for your objective, or you can make your own (as I've done here with the function green defined below):
cmaps = {@jet @parula @turbo @colorcube @green};
% demonstrating different colormap's colors:
nc = numel(cmaps);
for ii = 1:nc
ax = subplot(1,nc,ii);
set(ax, ...
'ColorMap',cmaps{ii}(16), ...
'Visible','off');
cb = colorbar( ...
'Position',[(ii-1+0.125)/nc 0 0.75/nc 1], ...
'YTick',[]);
set(get(cb,'Label'), ...
'Rotation',0, ...
'Position',[0.5 0.5 0], ...
'String',func2str(cmaps{ii}), ...
'FontSize',12, ...
'VerticalAlignment','middle');
end
function c = green(n)
c = zeros(n,3);
c(:,2) = linspace(0,1,n);
end
For a complete list of built-in colormaps (and how to make your own), see: colormap

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by