Thread Subject: Colomap question

Subject: Colomap question

From: Ken Fleisher

Date: 2 Jan, 2008 21:41:28

Message: 1 of 5

Hello. I have the following:

% spectrumRGB is a 301x3 matrix of RGB values
colormap( spectrumRGB );
figure;
Sh = scatter( 400:700, cie.illD65, 50, 1:n, 'filled' );

This code works correctly and the colors are as expected.
However, the following code does not produce the same
results and I cannot figure out why.

figure;
Sh = scatter( 400:700, cie.illD65, 50, spectrumRGB, 'filled' );

Can someone explain why these do not produce the same colors
on my plot? Thanks in advance.

Ken

Subject: Colomap question

From: Ian Clarkson

Date: 2 Jan, 2008 22:11:45

Message: 2 of 5

"Ken Fleisher" <k-fleisher.donotspamme@nga.gov> wrote in
message <flh0e8$smu$1@fred.mathworks.com>...
> Hello. I have the following:
>
> % spectrumRGB is a 301x3 matrix of RGB values
> colormap( spectrumRGB );
> figure;
> Sh = scatter( 400:700, cie.illD65, 50, 1:n, 'filled' );
>
> This code works correctly and the colors are as expected.
> However, the following code does not produce the same
> results and I cannot figure out why.
>
> figure;
> Sh = scatter( 400:700, cie.illD65, 50, spectrumRGB,
'filled' );
>
> Can someone explain why these do not produce the same
colors
> on my plot? Thanks in advance.
>
> Ken

Hi Ken,

After a bit of testing, I have a guess: when you use
colormap to set a default color map for a figure, if
there's no figure open, it creates a new one. But you call
a NEW figure, whose default goes back to the jet colormap.
Try doing the scatter plot FIRST, and then call colormap to
change it. Both options should then give the same results.

Subject: Colomap question

From: Ken Fleisher

Date: 3 Jan, 2008 12:42:29

Message: 3 of 5

Thanks for looking into this, but I don't think that's it.
The code where I call the colormap is the one that "does"
work. It's when I next supply scatter with the RGB triplets
directly that it seems to fail. Now, it's possible that my
RGB values are being displayed correctly, but why then would
the colormap code display something different (which happens
to be more like what I expect it to be--namely the pure
spectral colors).

I should also note that I get the same "incorrect" result
when I use the RGB triplets with the plot() function to fill
in the color below the spectrum. (I'm trying to plot a
spectrum, such as D65, and fill in the graph between the
x-axis and the D65 line with the spectral colors that
correspond to the wavelength.)

Thanks.

Ken

Subject: Colomap question

From: Ian Clarkson

Date: 3 Jan, 2008 14:23:00

Message: 4 of 5

Hmm. My guess would be that it's exactly what you say the
problem is -- I think it may actually be working and you're
just not realizing it? Try setting your colormap, instead
of spectrum RGB, to a random vector like I did. See if it
changes when you replot it. Then set the vector to all red,
or something. Try it again. If the graph is responding, and
showing up in the proper colours, then it's probably
working.

Note that the default colormap IS jet, which, when plotted
over a range, does go from blue -> green -> red. It may
appear to be what you're looking for when in fact your
spectrumRGB vector is correct. I'm not quite sure how to
help you anymore than this, seeing as I can't make my code
break like yours without using the data you are.

"Ken Fleisher" <k-fleisher.donotspamme@nga.gov> wrote in
message <flil7l$8o6$1@fred.mathworks.com>...
> Thanks for looking into this, but I don't think that's it.
> The code where I call the colormap is the one that "does"
> work. It's when I next supply scatter with the RGB
triplets
> directly that it seems to fail. Now, it's possible that my
> RGB values are being displayed correctly, but why then
would
> the colormap code display something different (which
happens
> to be more like what I expect it to be--namely the pure
> spectral colors).
>
> I should also note that I get the same "incorrect" result
> when I use the RGB triplets with the plot() function to
fill
> in the color below the spectrum. (I'm trying to plot a
> spectrum, such as D65, and fill in the graph between the
> x-axis and the D65 line with the spectral colors that
> correspond to the wavelength.)
>
> Thanks.
>
> Ken

Subject: Colomap question

From: Ken Fleisher

Date: 3 Jan, 2008 15:36:56

Message: 5 of 5

Thanks for the input. I tried putting my colormap call after
the Figure call, and sure enough, now both versions appear
"incorrect"!!! It seems my RGB values are not what I thought
they were and I was being thrown off because I thought it
was working correctly with the colormap call. In fact, the
Jet colormap is essentially what I'm after, so I may just
use that in the end!

Thanks again for the input.

Ken

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
colormap Ken Fleisher 2 Jan, 2008 16:44:58
scatter Ken Fleisher 2 Jan, 2008 16:44:58
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com