1
votes

I have the following data:

  • dataMatrix (20x210): 20 samples with 210 variables each
  • wavelength: 1 row of 210 variables describing the wavelength number
  • concentrations: concentration value for each sample (20 rows and 1 column)

I usually plot the data in a normal way:

plot(wavelength, dataMatrix)

But what I want is to plot and color each sample according to the concentration value taking into account the rest, color based on data. I think it is something to do with colormap. The result would be something like this:

Is there any easy way to do this using Matlab?

Thank you very much!

1
Nice question (y) same problem here - 16per9

1 Answers

0
votes

plot accepts line property including line color, like

plot(wavelength, dataMatrix, 'Color', [0,0,0.1])

colormap can convert built-in color maps to RGB matrices, like

nlines = length(concentrations);
cmap = hsv(nlines)

mapping concentration to color could be as easy as sorting the numbers

c = concentrations - min(concentrations);
c = ceil( c/max(c)*nlines );

finally, draw each line separately

for ii = 1:nlines
    plot(wavelength, dataMatrix(ii,:), 'Color', cmap(c(ii),:))
    hold on
end
hold off