Filter löschen
Filter löschen

How can I plot two images with different colormaps in a tiledlayout format?

42 Ansichten (letzte 30 Tage)
Suppose I am trying to plot two images: one in "jet" colormap format and the other in "parula" colormap format. I tried this code:
A=rand(604,584);
B=rand(604,584);
x=1:584;
y=1:604;
figure;
t=tiledlayout(1,2,'TileSpacing','none','Padding','none');
nexttile;
mymap=pcolor(x,y,A);
mymap.EdgeAlpha=0;
c = jet;
colormap(c);colorbar;
nexttile;
mymap=pcolor(x,y,B);
mymap.EdgeAlpha=0;
c = parula;
colormap(c);colorbar;
But both the figures are exhibiting only parula colormaps (the colormap code provided at the end of the code). How can I get distinct colormaps for different figures of a tiledlayout subplot?

Akzeptierte Antwort

Abhishek Chakraborty
Abhishek Chakraborty am 12 Mär. 2023
A=rand(604,584);
B=rand(604,584)+2;
x=1:584;
y=1:604;
figure;
t = tiledlayout(1,2,'TileSpacing','none');
ax1 = nexttile;
mymap=pcolor(x,y,A);mymap.EdgeAlpha=0;
colormap(ax1,jet);
colorbar(ax1);
title(ax1,'Image 1');
ax2 = nexttile;
mymap=pcolor(x,y,B);mymap.EdgeAlpha=0;
colormap(ax2,parula);
colorbar(ax2);
title(ax1,'Image 2');
% Set the colormaps for each subplot explicitly
colormap(ax1,jet);
colormap(ax2,parula);
t.Padding = 'none';

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by