How to assign the color intervals while using the jet color chart?
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!