matrix - Matlab - plot and color samples based on data -
i have following data:
- datamatrix (20x210): 20 samples 210 variables each
- wavelength: 1 row of 210 variables describing wavelength number
- concentrations: concentration value each sample (20 rows , 1 column)
i plot data in normal way:
plot(wavelength, datamatrix)
but want plot , color each sample according concentration value taking account rest, color based on data. think colormap. result this:
is there easy way using matlab?
thank much!
plot
accepts line property including line color,
plot(wavelength, datamatrix, 'color', [0,0,0.1])
colormap
can convert built-in color maps rgb matrices,
nlines = length(concentrations); cmap = hsv(nlines)
mapping concentration color easy sorting 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
Comments
Post a Comment