Color "Thermometer" for different shaded functions

Hi
I have a page of subplots each of which contains a function (a distribution to be more precise). Now each function has a different shade of color according to a certain property. Lets say the more a distribution diverges from a normal the more redish it becomes. What I want to plot next to these subplots now is sort of a thermometer with this color progression where it would be marked at the start of this thermometer "lowest divergence from normal" and at the end "highest convergence ..." etc. Of course it should not look like a real thermometer - how could I do that?
Thanks

Answers (1)

You could use one of the built-in colormaps, such as jet, hot, winter, etc. to get your color:
% Create a color map.
thePlotsColorMap = jet(256);
% Calculate your "temperature"
theTemp = whatever....
% Normalize it to 1-256.
colorMapIndex = 256 * (theTemp - minTemp) / (maxTemp - minTemp);
% Get this particular color out of the color map.
colorToPlotWith = jet(colorMapIndex);
% Now call plot with the 'Color' option set to this
plot(x, y, 'Color', colorToPlotWith);

5 Comments

I am not sure if I understand you correctly. I already have my distributions in different shades. So I have the Kullback-Leibler divergence for each subplot. These divergences are then normalized between 0 and 1 and plottet with colors [kl 0 1-kl]. Now I want a colorbar for these colors plottet on the same page. Do you know what I mean? thanks :-)
Perhaps it is because you forgot to upload a screenshot so people could better understand what you've done so far. It would also be good if you could mock up a screenshot of what you'd like it to look like.
I would have, but the code is really lengthy!
I figured out in the meantime. Thanks a lot nevertheless!

Sign in to comment.

Tags

Asked:

on 4 Feb 2013

Community Treasure Hunt

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

Start Hunting!