Change colormap on contour plot.

I have a chart that looks like
Screen Shot 2019-02-27 at 11.29.49 AM.png
Can anyone help me out with changing the color gradation so that the minimum value is red and the maximum value is blue?
Thank you so much!

답변 (1개)

Walter Roberson
Walter Roberson 2019년 2월 27일

0 개 추천

colormap(flipud(jet))
This will have green and yellow and orange in the middle, but you didn't say it couldn't ;-)
If you only want red and blue, then you will need to describe how you want the colors to evolve. Is it acceptable to go through purple in the middle?

댓글 수: 2

Sung Yeob Lim
Sung Yeob Lim 2019년 2월 27일
Thanks for the response.
Essentially I want an RGB color gradation. So the red will go through green and then go onto blue.
Walter Roberson
Walter Roberson 2019년 2월 27일
편집: Walter Roberson 2019년 2월 27일
N = size(colormap(),1); %size of existing colormap
assert(mod(N,2) == 1, 'Code cannot handle colormap with even number of entries')
v = linspace(0,1,floor(N/2)+1);
v = v(1:end-1); %throw out the 1 exactly
z = zeros(size(v));
r = [1, fliplr(v), 0, z, 0];
g = [v, 1, fliplr(v)];
b = [z, 0, v];
cmap = [r(:), g(:), b(:)];
colormap(cmap)
... Something like that. I am having a bit of trouble with the boundary conditions.
The colormap needs to be an odd size because the green in the center needs to be unique and presumably you want the red->green size to be the same as the green->blue size.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Orange에 대해 자세히 알아보기

질문:

2019년 2월 27일

편집:

2019년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by