フィルターのクリア

how to define a gradient colormap

34 ビュー (過去 30 日間)
ali eskandari
ali eskandari 2021 年 3 月 4 日
編集済み: ali eskandari 2021 年 3 月 4 日
I have different matrices with elements between zero and one, then I want to subtract some of them from each other and plot the output result on a gradient-scale colormap to see where the differences have happened.
I used imagesc to show the subtracted matrix, but the problem is that this function applies a map according to the range of the input matrix. For instance, in one case blue colour is mapped to -1, in another case blue might be map to another value. While I want to have a fix gradient map for values between -1 and 1. Is it possible to do that in Matlab?
For example, in plot one, the range of gradient is [-1,1], while on the others there is blue or red is assigned to different values. In fact, I want to see the effect of subtraction in different matrices while in the current colormap, I cannot understand whether there is any huge difference between them or not.

採用された回答

Jorg Woehl
Jorg Woehl 2021 年 3 月 4 日
Yes, you can use a fixed colormap by executing the following command each time you plot an image:
caxis([-1 1])
This will map all image points with values of -1 (or smaller) to the first row of the colormap (blue, in your case), and map all points with values of 1 (or higher) to the last row of the colormap (red).
Alternatively, you can call imagesc directly by supplying these color mapping limits:
imagesc(___, [-1 1])
  1 件のコメント
Adam Danz
Adam Danz 2021 年 3 月 4 日
+1 Good idea to suggest the clim input, @Jorg Woehl

サインインしてコメントする。

その他の回答 (1 件)

Adam Danz
Adam Danz 2021 年 3 月 4 日
編集済み: Adam Danz 2021 年 3 月 4 日
You need to define the colorscale using caxis.
caxis([-1,1])
to apply to all axes,
arrayfun(@(h)caxis(h,[.2,.6]),ax) % ax is an array of axis handles.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by