How can i change the color of one mark in colorbar?

조회 수: 2 (최근 30일)
Joanna Sliwa
Joanna Sliwa 2017년 6월 5일
댓글: Kenta 2020년 7월 16일
For example, I like the colorbar 'jet', but I want the cyan mark to be in different color. I was changing it manually but it's really tedious if I have a lot of plots. Can I change it in code?

채택된 답변

KSSV
KSSV 2017년 6월 6일
편집: KSSV 2017년 6월 6일
Get the colormap values, find the respective color (RGB) you want to change and replace it with your desired (RGB) color. Check the below code.
[X,Y,Z] = peaks(25) ;
figure(1)
surf(X,Y,Z)
colorbar
c = colormap(jet) ;
title('original jet')
figure(2)
idx = find(ismember(c,[0 1 1],'rows')) ; % get cyan color index
c(idx,:) = [0 0 0] ; % change cyan to black
surf(X,Y,Z)
colorbar
colormap(c)
title('Cyan in jet changed to black')
  댓글 수: 1
Kenta
Kenta 2020년 7월 16일
I was searching for this info. It helped me a lot. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by