Effacer les filtres
Effacer les filtres

Colormap setting the colors i want

121 vues (au cours des 30 derniers jours)
Tiago Dias
Tiago Dias le 29 Juin 2018
Commenté : Tiago Dias le 2 Juil 2018
Hello, So I discovered Colormap, and I want to draw a Color map of a matrix A I got that has ranges from 0 to 1. But I don't want to use the colours Matlab provides (jet for example), I want to create my own. Green for 0, Red for 1, and in between a mix from red, yellow for 0.5, orange and then red. A bit like Excel does.
colormap('jet');
imagesc(A);
colorbar;
Thanks
  2 commentaires
Stephen23
Stephen23 le 29 Juin 2018
"But I don't want to use the colours Matlab provides..."
As well as the ones that MATLAB provides:
you can find plenty of colormaps on FEX:
Tiago Dias
Tiago Dias le 29 Juin 2018
I would like to create one has simples as Excel, red to green or green to red, with orange for middle values

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 29 Juin 2018
Modifié(e) : Stephen23 le 29 Juin 2018
You can easily adjust colormaps by using the colormapeditor:
As an alternative to defining the colormap matrix "by hand", you could use one of the colormap generators/creators on MATLAB FEX:
Some of them allow you to create a whole colormap from just a few RGB colors, e.g.:
  3 commentaires
Tiago Dias
Tiago Dias le 2 Juil 2018
Modifié(e) : Tiago Dias le 2 Juil 2018
I tried to do this to save my colormap like this:
ax = gca;
mymap = colormap(ax);
save('MyColormap','mymap')
when I make
imagesc(B)
colormap mymap
colorbar
the colours are not what I saved previously, he uses Panula by default, because he doenst recognize mymap has a type of colours.
Tiago Dias
Tiago Dias le 2 Juil 2018
Nevermind, i was typing it wrong
colormap(mymap)
works perfect, thanks for your first link it helped me a lot :)

Connectez-vous pour commenter.

Plus de réponses (2)

Image Analyst
Image Analyst le 29 Juin 2018
Create your own colormap then assign values in whatever way you want:
numColors = 256; % Whatever....
myColorMap = zeros(numColors, 3); % Col1 = red, col2 = green, col3 = blue.
myColorMap(row1:row2, 1); % Set red values however you want.
... etc...
% Apply it.
colormap(handlesToMyAxes, myColorMap);
% Show bar
colorbar;
  9 commentaires
Image Analyst
Image Analyst le 29 Juin 2018
Please attach your matrix "A" in a .mat file.
Tiago Dias
Tiago Dias le 2 Juil 2018
I got a lot of values from 0 to 1, and my objective is to creat 10 intervals of colours 0,0.1,0.2,0.3,...,1.0 from red to green like excel does.

Connectez-vous pour commenter.


Wooshik Kim
Wooshik Kim le 29 Juin 2018
Modifié(e) : Wooshik Kim le 29 Juin 2018
You can set your own colormap with the following
mymap = [0 0 0.3 0 0 0.4 0 0 0.5 0 0 0.6 0 0 0.8 0 0 1.0]; colormap(mymap)
where each column corresponds to Red, Green, Blue intensities between 0 and 1.
The following page might be helpful.
  1 commentaire
Tiago Dias
Tiago Dias le 29 Juin 2018
ok, will try

Connectez-vous pour commenter.

Catégories

En savoir plus sur Orange 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