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

2 Ansichten (letzte 30 Tage)
Joanna Sliwa
Joanna Sliwa am 5 Jun. 2017
Kommentiert: Kenta am 16 Jul. 2020
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?

Akzeptierte Antwort

KSSV
KSSV am 6 Jun. 2017
Bearbeitet: KSSV am 6 Jun. 2017
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 Kommentar
Kenta
Kenta am 16 Jul. 2020
I was searching for this info. It helped me a lot. Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Color and Styling 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!

Translated by