Effacer les filtres
Effacer les filtres

How to write the colormap code for the colorbar presented in the figure?

1 vue (au cours des 30 derniers jours)
How to write the colormap code for the colorbar presented in the figure?
  1 commentaire
KSSV
KSSV le 22 Déc 2018
Colorbar depends on the data you have.....do you have data?

Connectez-vous pour commenter.

Réponse acceptée

David Goodmanson
David Goodmanson le 22 Déc 2018
Modifié(e) : David Goodmanson le 22 Déc 2018
Hi Naresh,
Even if all you have is the jpg you can still make progess. I called the the jpg image A, and
figure(1)
image(A)
Then you can use the data cursor option to take a look at the the top and bottom ends of the colorbar. I found that the colorbar runs from pixels y = 7 to 200 along a typical line x = 352. For reasons I can never quite remember you need to reverse the coordinates to find
cm = squeeze(A(7:200,352,:));
which produces a colormap matrix of size 194 x 3. Then
x = 1:size(cm,1);
figure(2)
plot(x,cm(:,1),'r',x,cm(:,2),'g',x,cm(:,3),'b')
shows the following:
This does not appear to be a named Matlab colormap. As you can see, it starts out red, then after a not-so-obvious percentage of the total horizontal span it becomes r+g = yellow, then drops down to black and ends up white.
(Since the pixels were taken from top to bottom, the colormap cm should actually be flipped top to bottom. Then the plot above would be flipped from left to right and low index values would correspond to the bottom end of the colorbar).
The fact that there are 194 points doesn't necessarly mean anything. Matlab often scales the data between colormap end points, in which case this could be redone with any number of points as long as there are enough to make the colorbar colors look continuous (see 'caxis'). It's the percentage of the horizontal span at the break points that matters.

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by