フィルターのクリア

Change the range of a specific color in a colormap

20 ビュー (過去 30 日間)
Manuel Suazo
Manuel Suazo 2022 年 10 月 28 日
コメント済み: Manuel Suazo 2022 年 10 月 29 日
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

採用された回答

Walter Roberson
Walter Roberson 2022 年 10 月 29 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRed についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by