MATLAB Examples

alt_4_2.m

Scatter plot with color.

load rubber

data = [Hardness TensileStrength AbrasionLoss];
label = {'Hardness' 'Tensile Strength' 'Abrasion Loss'};
x = Hardness;
y = TensileStrength;
z = AbrasionLoss;

%  Make color map index.
%  Define number of colors.
nColor = 20;
%  Make a normalized variable from abrasion loss.
offset = 1;
c = AbrasionLoss-min(AbrasionLoss);
c = round((nColor-1-2*offset)*c/max(c)+1+offset);

%  Scatter plot with abrasion loss as color.
scatter(x,y,6,c,'filled')
xlabel('Hardness')
ylabel('TensileStrength')
title('Rubber')
box on
colormap(hot(nColor))

%  Associate darker color with higher loss.
mymap = colormap;
colormap(flipud(mymap))
hg = colorbar;

%  Put meaningful labels on colorbar.
[cu,ii,jj] = unique(c);
au = AbrasionLoss(ii);
barTick = get(hg,'YTick');
barLabel = round(interp1(cu,au,barTick));
set(hg,'YTickLabel',barLabel)

%  Modify color map.
brighten(-0.5)