Customize a colormap
이전 댓글 표시
- Hello,I would like to customize a colormap to be able to have four regions. Example, for x>1 (red); for 0.1<x<1 (orange); for 0.01<x<0.1 (yellow); for x<0.01 (green).It can be linear interpolated between the intervals or just plain simple.Any help is appreciated.Thanks,Hugo Policarpo
채택된 답변
추가 답변 (2개)
Walter Roberson
2011년 8월 26일
0 개 추천
colormaps cannot be used like that, not unless you are able to define a strict lower and upper bound on x. pseudocolor works by mapping the lowest data value to the lowest color, and the highest data value to the highest color, with everything in-between linearly interpolated according to (x-min(x)) .* (number_of_map_entries ./(max(x)-min(x)))
If you want particular fixed data values to map to particular colors, then you will need to either use RGB instead of pseudocolor (choosing the RGB color yourself), or else you will need to create a color map that has as many entries as different states you want and then map your data to the state number before submitting it to be plotted.
댓글 수: 2
Daniel Shub
2011년 8월 26일
You do not need to bound x. You can just bound CLim and replace x with CLim in your equation.
Hugo Policarpo
2011년 8월 26일
Daniel Shub
2011년 8월 26일
mesh(peaks)
colorbar
set(gca, 'CLim', [0, 1.01])
set(gcf, 'ColorMap', [0, 1, 0; repmat([1, 1, 0], 9, 1); repmat([1, 0.5, 0], 90, 1); [1, 0, 0]])
댓글 수: 2
Hugo Policarpo
2011년 8월 26일
Daniel Shub
2011년 8월 26일
See my edit. It now gives the correct answer without any "rounding" issues.
카테고리
도움말 센터 및 File Exchange에서 Red에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!