Borrar filtros
Borrar filtros

Change the range of a specific color in a colormap

20 visualizaciones (últimos 30 días)
Manuel Suazo
Manuel Suazo el 28 de Oct. de 2022
Comentada: Manuel Suazo el 29 de Oct. de 2022
Hi, I have a data visualization problem with a divergence color map, what I want to do is to assign for a specific color a range manually delimited by me, is there any way to do it?. For example in the map below I want the correlation values for the first red color (after white) only take values between 0.2 and 0.4.
the map

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Oct. de 2022
The function expects positions in the range 0 to 1, so you will need to rescale() your valid key values from whatever fixed range they have now to the [0 1] range.It looks like you might have the range -1 to +1 so add 1 to the key values and divide the result by 2 to get the [0 1] position for the purposes of the function.
Then when you colormap() the new map into place, be sure the caxis([-1 1]) or as appropriate the fixed values.
Each "slot" in a colormap is exactly the same size: for a colormap with N rows, each entry in the colormap covers 1/N of the defined range of values. It is not possible to say that 0.2 to 0.4 is a single slot that is one color but that other slots are to be different widths. If you want different colors in the map to represent different data spans, then what you have to do is use more rows in the colormap but repeat individual colors. For example if you had one color of desired width 0.2 and another of desired width 0.18 then you could use enough rows that an individual slot covered 0.02 of the range, and the 0.2 repeated a color 10 times and the 0.18 repeated it color 9 times. You cannot just create a colormap with arbitrary breakspoints, colormap processing is always a linear mapping process.

Más respuestas (0)

Categorías

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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by