How do I change the type of colorbar for each tiled figure?
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have a figure with 4 tiles and manually edited the colorbar and made a new colorbar scheme in the matlab figure, but it only applies to my last tile. How do I get all of them to have the same colorbar scheme?
This is my code:
figure;
tiledlayout(1,4,'TileSpacing','Compact');
%Tile 1
nexttile
imagesc(TTest_DIF)
xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12);
ylabel('{\it β}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12)
xticklabels({0 "" 0.2 "" 0.4 "" 0.6 "" 0.8 "" 1})
set(gca, 'xtick', 1:11, 'XTickLabel', xticklabels)
yticklabels({1 "" "" "" "" 0})
set(gca, 'ytick', 1:6, 'YTickLabels', yticklabels)
title('{\Delta_t - \Delta_c}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 14)
clim([-72 11]) % EDIT THESE LIMITS
%Tile 2
nexttile
imagesc(BSITTest_DIF)
%xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 10);
ylabel('{\it β}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12)
xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12);
xticklabels({0 "" 0.2 "" 0.4 "" 0.6 "" 0.8 "" 1})
set(gca, 'xtick', 1:11, 'XTickLabel', xticklabels)
yticklabels({1 "" "" "" "" 0})
set(gca, 'ytick', 1:6, 'YTickLabels', yticklabels)
title('{\Delta_B_I_T - \Delta_c}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 14)
clim([-72 11]) % EDIT THESE LIMITS
%tile 3
nexttile
imagesc(Slope_DIF)
%had to change to DeltaSlopeE' in workspace as it was 11x6 not 6x11.
%xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 10);
ylabel('{\it β}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12)
xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12);
xticklabels({0 "" 0.2 "" 0.4 "" 0.6 "" 0.8 "" 1})
set(gca, 'xtick', 1:11, 'XTickLabel', xticklabels)
yticklabels({1 "" "" "" "" 0})
set(gca, 'ytick', 1:6, 'YTickLabels', yticklabels)
title('{\Delta_s - \Delta_c}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 14)
clim([-72 11])
%tile 4
nexttile
imagesc(Slope_BIT_DIF)
%had to change to DeltaSlopeE' in workspace as it was 11x6 not 6x11.
%xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 10);
ylabel('{\it β}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12)
xlabel('{\it a}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 12);
xticklabels({0 "" 0.2 "" 0.4 "" 0.6 "" 0.8 "" 1})
set(gca, 'xtick', 1:11, 'XTickLabel', xticklabels)
yticklabels({1 "" "" "" "" 0})
set(gca, 'ytick', 1:6, 'YTickLabels', yticklabels)
title('{\Delta_s - \Delta_B_I_T}', 'FontWeight', 'bold', 'FontName', 'TimesNewRoman', 'FontSize', 14)
clim([-72 11])
% colorbar
clim([-72 11]) % EDIT THESE LIMITS
cb = colorbar;
cb.Layout.Tile = 'south'
cb.Position = cb.Position + 1e-10;
set(gcf,'PaperSize',[8.5 11])
This is the image:

Thank you in advance :)
0 Kommentare
Antworten (1)
Akira Agata
am 20 Okt. 2023
% sample data
z = peaks(20);
% display the data with different colormap
tiledlayout(1, 4);
ax1 = nexttile;
imagesc(z)
colormap(ax1, "parula")
colorbar("southoutside")
ax2 = nexttile;
imagesc(z)
colormap(ax2, "hsv")
colorbar("southoutside")
ax3 = nexttile;
imagesc(z)
colormap(ax3, "abyss")
colorbar("southoutside")
ax4 = nexttile;
imagesc(z)
colormap(ax4, "autumn")
colorbar("southoutside")
2 Kommentare
Akira Agata
am 23 Okt. 2023
@Jric-san
Yes, you can use your custom colormap in the same way, like:
% sample data
z = peaks(20);
% custom colormap
cMap = [1 0 0; 0 1 0; 0 0 1];
% display the data with different colormap
tiledlayout(1, 4);
ax1 = nexttile;
imagesc(z)
colormap(ax1, "parula")
colorbar("southoutside")
ax2 = nexttile;
imagesc(z)
colormap(ax2, "hsv")
colorbar("southoutside")
ax3 = nexttile;
imagesc(z)
colormap(ax3, "abyss")
colorbar("southoutside")
ax4 = nexttile;
imagesc(z)
colormap(ax4, cMap) % <- custom colormap
colorbar("southoutside")
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!