Unable to apply separate colormaps and display in subplots
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Green 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!