I'd like to create a color palette between two colors. For instance between Blue and Red with 20 or 50 instances.
How can this be achieved in Matlab R2014b?
I'd like to create a color palette between two colors. For instance between Blue and Red with 20 or 50 instances.
How can this be achieved in Matlab R2014b?
You can use any kind of interpolation (e.g.
interp1
) to create your own custom colormap between two colors or multiple colors. A colormap is basically a 3-column matrix with RGB-values. In your case its pretty simple, as you just need red with[1 0 0]
and blue[0 0 1]
and linearly interpolated in between.linspace
is therefore the best choice.Note that you could also use the the colormap GUI by typing
colormapeditor
.Alternative you can also use 2D-interpolation:
And just another example using spline-interpolation to get wider areas of blue and red:
Or use any mathematical function you want: