Thread Subject: Grey color of certain values in a jet colormap

Subject: Grey color of certain values in a jet colormap

From: Brian Bak

Date: 26 Nov, 2009 16:44:12

Message: 1 of 5

Hi
I have a color plot using the colormap(jet(40)). Does anyone know if it is possible to assign the color grey to specific values of the matrix DATA, see below, and color all other values by the jet(40) colormap?

figure(1)
patch('Vertices',nodes,'Faces',elements, 'FaceVertexCData', DATA,'FaceColor','flat', 'LineStyle', 'none')
colormap(jet(40))


Thanks in advance

Best regards
Brian

Subject: Grey color of certain values in a jet colormap

From: Bjorn Gustavsson

Date: 26 Nov, 2009 17:07:01

Message: 2 of 5

"Brian Bak" <brianlvbak@gmail.com> wrote in message <hemb8s$nvd$1@fred.mathworks.com>...
> Hi
> I have a color plot using the colormap(jet(40)). Does anyone know if it is possible to assign the color grey to specific values of the matrix DATA, see below, and color all other values by the jet(40) colormap?
>
> figure(1)
> patch('Vertices',nodes,'Faces',elements, 'FaceVertexCData', DATA,'FaceColor','flat', 'LineStyle', 'none')
> colormap(jet(40))
>
You could star towards something like that by:
cmp = jet(40);
cmp(indx,:) = [1,1,1]*graylevel;
colormap(cmp)
Of course this will only set the selected entries in cmp to grey of your selected greylevel, leading to all values in the corresponding data ranges to grey. If you want to refine the selection of greyed out values I guess you'd have to use a longer colormap, but if you want a 40-long jet you could just run interp1 with method nearest to retain the number of unique colours.

HTH,
Bjeorn

Subject: Grey color of certain values in a jet colormap

From: Brian Bak

Date: 26 Nov, 2009 17:45:22

Message: 3 of 5

"Bjorn Gustavsson" <bjonr@irf.se> wrote in message <hemcjk$g3l$1@fred.mathworks.com>...
> "Brian Bak" <brianlvbak@gmail.com> wrote in message <hemb8s$nvd$1@fred.mathworks.com>...
> > Hi
> > I have a color plot using the colormap(jet(40)). Does anyone know if it is possible to assign the color grey to specific values of the matrix DATA, see below, and color all other values by the jet(40) colormap?
> >
> > figure(1)
> > patch('Vertices',nodes,'Faces',elements, 'FaceVertexCData', DATA,'FaceColor','flat', 'LineStyle', 'none')
> > colormap(jet(40))
> >
> You could star towards something like that by:
> cmp = jet(40);
> cmp(indx,:) = [1,1,1]*graylevel;
> colormap(cmp)
> Of course this will only set the selected entries in cmp to grey of your selected greylevel, leading to all values in the corresponding data ranges to grey. If you want to refine the selection of greyed out values I guess you'd have to use a longer colormap, but if you want a 40-long jet you could just run interp1 with method nearest to retain the number of unique colours.
>
> HTH,
> Bjeorn

Hi Bjeorn

Thank you for the answer.

Can you elaborate further. I can't get it to work.

Subject: Grey color of certain values in a jet colormap

From: Brian Bak

Date: 26 Nov, 2009 18:17:03

Message: 4 of 5

"Bjorn Gustavsson" <bjonr@irf.se> wrote in message <hemcjk$g3l$1@fred.mathworks.com>...
> "Brian Bak" <brianlvbak@gmail.com> wrote in message <hemb8s$nvd$1@fred.mathworks.com>...
> > Hi
> > I have a color plot using the colormap(jet(40)). Does anyone know if it is possible to assign the color grey to specific values of the matrix DATA, see below, and color all other values by the jet(40) colormap?
> >
> > figure(1)
> > patch('Vertices',nodes,'Faces',elements, 'FaceVertexCData', DATA,'FaceColor','flat', 'LineStyle', 'none')
> > colormap(jet(40))
> >
> You could star towards something like that by:
> cmp = jet(40);
> cmp(indx,:) = [1,1,1]*graylevel;
> colormap(cmp)
> Of course this will only set the selected entries in cmp to grey of your selected greylevel, leading to all values in the corresponding data ranges to grey. If you want to refine the selection of greyed out values I guess you'd have to use a longer colormap, but if you want a 40-long jet you could just run interp1 with method nearest to retain the number of unique colours.
>
> HTH,
> Bjeorn

Hi Bjeorn

Now I see what you mean. Do you know why i get the color black no matter what i set the value of graylevel to?

Subject: Grey color of certain values in a jet colormap

From: Steven Lord

Date: 28 Nov, 2009 23:49:12

Message: 5 of 5


"Brian Bak" <brianlvbak@gmail.com> wrote in message
news:hemb8s$nvd$1@fred.mathworks.com...
> Hi
> I have a color plot using the colormap(jet(40)). Does anyone know if it is
> possible to assign the color grey to specific values of the matrix DATA,
> see below, and color all other values by the jet(40) colormap?
>
> figure(1)
> patch('Vertices',nodes,'Faces',elements, 'FaceVertexCData',
> DATA,'FaceColor','flat', 'LineStyle', 'none')
> colormap(jet(40))

Add grey to the end of the colormap.

colormap([jet(40); gray(1)]) % or just append [1 1 1] to jet(40)
colorbar

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com