function c = data_to_color(x,x_lim,cmap)

    i = round( (size(cmap,1)-1).*( (x-x_lim(1))./(x_lim(2)-x_lim(1)))) +1;
    i = max(1,min(size(cmap,1), i ) );
    c = cmap( i  ,:);
end