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

17 Ansichten (letzte 30 Tage)
anaconpa
anaconpa am 4 Dez. 2021
Beantwortet: Atsushi Ueno am 4 Dez. 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に変わってしまう

Akzeptierte Antwort

Atsushi Ueno
Atsushi Ueno am 4 Dez. 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に変わってしまう

Weitere Antworten (0)

Kategorien

Mehr zu カラーマップ finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!