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

조회 수: 14 (최근 30일)
anaconpa
anaconpa 2021년 12월 4일
답변: Atsushi Ueno 2021년 12월 4일
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に変わってしまう

채택된 답변

Atsushi Ueno
Atsushi Ueno 2021년 12월 4일
% 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に変わってしまう

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 カラーマップ에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!