subplotで異な​る色のカラースケール​を使用する方法

19 views (last 30 days)
anaconpa
anaconpa on 4 Dec 2021
Answered: Atsushi Ueno on 4 Dec 2021
subplotで複数のカラーマップを表示するときに,それぞれ別のカラースケールを使用することはできますか?
以下の疑似コードのように1つ目をjet,2つ目をcoolにしたい場合,以下のタイミングでcolormapを呼ぶとすべてのカラースケールがcoolに変わってしまいます.
よろしくお願いいたします
subplot(2,1,1)
imagesc(..)
colormap(jet)
subplot(2,1,2)
imagesc(..)
colormap(cool)% ←このタイミングでsubplot(2,1,1)もcoolに変わってしまう

Accepted Answer

Atsushi Ueno
Atsushi Ueno on 4 Dec 2021
% The trick is to use gca as the target in colormap.
% そのコツは、colormapのターゲットとしてgcaを使うことです。
% ターゲット。次の値のいずれかとして指定します。
% Figure オブジェクト。Figure のカラーマップは、Figure 内のすべての座標軸のプロットに適用されます。
% Axes オブジェクト、PolarAxes オブジェクト、または GeographicAxes オブジェクト。Figure 内の異なる座標軸に対して、固有のカラーマップを定義できます。
% Colormap プロパティをもつグラフィックス オブジェクト。たとえば、HeatmapChart オブジェクトのカラーマップの変更またはクエリができます。
load penny.mat
subplot(2,1,1)
imagesc(P)
colormap(gca,'jet') % colormap(jet)
subplot(2,1,2)
imagesc(P)
colormap(gca,'cool') % colormap(cool)% ←このタイミングでsubplot(2,1,1)もcoolに変わってしまう

More Answers (0)

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!