How to convert the below colormap into a Matlab colormap?

4 visualizaciones (últimos 30 días)
Leon
Leon el 3 de Nov. de 2021
Comentada: Leon el 3 de Nov. de 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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 3 de Nov. de 2021
Editada: Walter Roberson el 3 de Nov. de 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 comentarios
Leon
Leon el 3 de Nov. de 2021
Many thanks for the recommendations!
Leon
Leon el 3 de Nov. de 2021
BTW, how could I convert a color from something like "16/122/47" to the Matlab format of [0.2 0.7 0.8]?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by