필터 지우기
필터 지우기

Unable to apply separate colormaps and display in subplots

조회 수: 2 (최근 30일)
Big Ben
Big Ben 2022년 6월 14일
답변: DGM 2022년 6월 14일
I am trying to display a grayscale image with different colormaps in a subplot like so:
original = imread('cell.tif');
subplot(2,1,1); imagesc(original); axis('on', 'image'); title('Before'); colorbar; colormap("parula");
subplot(2,1,2); imagesc(original); axis('on', 'image'); title('After'); colorbar; colormap("turbo");
However, as can be seen in the result, I only get the turbo colormap in both the images.
Why does this happen? I was expecting the first image to have the parula colormap, and the second one to have the turbo colormap.

채택된 답변

DGM
DGM 2022년 6월 14일
You can fix that by explicitly specifying the axes in the call to colormap().
original = imread('cell.tif');
h1 = subplot(2,1,1);
imagesc(original);
axis('on', 'image');
title('Before');
colorbar;
colormap(h1,"parula");
h2 = subplot(2,1,2);
imagesc(original);
axis('on', 'image');
title('After');
colorbar;
colormap(h2,"turbo");

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by