How to convert the below colormap into a Matlab colormap?
    6 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Leon
      
 am 3 Nov. 2021
  
    
    
    
    
    Kommentiert: Leon
      
 am 3 Nov. 2021
            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 Kommentare
Akzeptierte Antwort
  Walter Roberson
      
      
 am 3 Nov. 2021
        
      Bearbeitet: Walter Roberson
      
      
 am 3 Nov. 2021
  
      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.
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Color and Styling finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!