This question already has an answer here:
I'm doing data-analysis in Matlab and I have data points from three different classes: (no-damage, small damage, and high damage). These classes are represented by integer values (1, 2, 3).
I'm predicting these classes by using regularized linear regression and I want to create a picture, where I have the data points highlighted with the colors: 1 = green, 2 = yellow, 3 = red. This is no problem to me, but what I would also like to is to create a secondary picture, where I have predicted these classes with my regression model. The problem is that my regression model doesn't give integer values but real values (I could overcome this by rounding the values to nearest integer, but I don't want to ;) )
What I would like to do is: map the real value (say 1.45) into a RGB-code, which would correspond to a color in the range green -- yellow -- red.
Let me give an example:
If the prediction value of my model is 1.45, then the corresponding color code would fall between green -- yellow.
If my prediction value is 2.5, then the color code would fall between yellow -- red.
So the closer the value is to 1, the closer the color code is to green, the closer the value is to 2, the closer the color code is to yellow and the closer the value is to 3, the closer the color code is to red.
I would only like to colors like greeb, yellow, orange, red in my prediction picture =)
Hope my question is clear =) Any good ideas? =)
Please let me know if my question is unclear =)
You can create your own colormap easily, you just need to define a Nx3 matrix with your colors. Let me show you an example code with the map you proposed.
Result: (NOTE, you may want to add more
n2
values so the red is more noticeable.