Apply colormap to plot(x,y)

Hi. I am plotting optical bandpass filters from measurments and want to colour each point depending on where it is on the spectrum. My x values are wavelength (488 = blue, 532 = green and 670 = red). For each point i plot, I want to be able to plot it in a colour that represents its true colour.
Im not sure how to firstly create the colormap, and secondly apply this to the plot(x,y function).

 채택된 답변

Andrew Newell
Andrew Newell 2011년 5월 11일

1 개 추천

To create the colormap, you could use spectrumRGB in Spectral and XYZ Color Functions.
EDIT: Here is a little demo.
n = 20;
x = rand(n,1); y = rand(n,1); spect = linspace(300,830,n);
sRGB = spectrumRGB(spect);
sRGB = squeeze(sRGB); % For some reason spectrumRGB returns a 3D array
figure; hold on
for i = 1:n
line(x(i),y(i),'Marker','*','Linestyle','none','Color',sRGB(i,:))
end
spectrumlabel(gca)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

태그

질문:

2011년 5월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by