How to convert the below colormap into a Matlab colormap?
조회 수: 4 (최근 30일)
이전 댓글 표시
Below is a topography colormap I got from the Generic Mapping Tools. I wonder if anyone knows how to convert this colormap into the format of a Matlab colormap, so that I can use it in my below command for my elevation plot?
contourf (X, Y, Z, [-10000:100:10000], 'LineStyle', 'none' );
Each row contains 4 parameters:
Column # 1 #2 #3 #4
Starting elevation, starting color (red/green/blue), ending elevation, ending color (red/green/blue).
0 100/150/100 30 100/150/100
30 125/175/125 60 125/175/125
60 150/200/150 122 150/200/150
122 175/225/175 183 175/225/175
183 200/255/200 244 200/255/200
244 212/255/212 305 212/255/212
305 255/255/225 457 255/255/225
457 255/225/175 610 255/225/175
610 255/225/125 702 255/225/125
702 255/175/75 914 255/175/75
914 200/150/50 1219 200/150/50
1219 175/125/50 1450 175/125/50
1450 150/100/50 1700 150/100/50
1700 150/125/100 1981 150/125/100
1981 125/125/125 2134 125/125/125
2134 150/150/150 2438 150/150/150
2438 175/175/175 2743 175/175/175
2743 200/200/200 3048 200/200/200
3048 233/233/233 3250 233/233/233
Many thanks!
댓글 수: 0
채택된 답변
Walter Roberson
2021년 11월 3일
편집: Walter Roberson
2021년 11월 3일
I suggest you look at https://www.mathworks.com/matlabcentral/fileexchange/69470-custom-colormap for the creation of the colormap given offsets and RGB information. That code can build color gradients -- though in your case I see that the colors are constant for each block.
I can see bins that are 61 values wide, and others that are 88, or 231 ... nothing that is nicely divisible into chunks. So you are pretty much going to need a colormap that is 30048 entries.
It is possible that your system cannot handle colormaps that are more than about 16384 entries; it might be necessary to fudge the boundaries a bit. For example if you rounded all the boundaries to even, then you could get away with half as many colormap entries.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!