Bluewhitered function in tiledlayout environment

1 回表示 (過去 30 日間)
Roderick
Roderick 2024 年 6 月 4 日
回答済み: DGM 2024 年 6 月 4 日
Dear all
I am using this nice customized function, https://es.mathworks.com/matlabcentral/fileexchange/4058-bluewhitered. When I use it in a tiledlayout environment, the individual colorbar for each of the plots is not centered in zero for the white colour:
u1=figure('visible','off','units','pixels','position',[0 0 1920 1080]);
tiledlayout("horizontal");
ax1=nexttile;
uimagesc(space_x,space_y,x);
axis xy;
colormap(gca,bluewhitered(256));
box on;
clr1=colorbar;
set(clr1,'TickLabelInterpreter','latex');
clim([-1 1]);
xlim([0 500]);
xticks([0:100:500]);
ylim([0 500]);
yticks([0:100:500]);
pbaspect([1 1 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',18);
ax2=nexttile;
uimagesc(space_x,space_y,y);
colormap(gca,bluewhitered(256));
axis xy;
box on;
clr2=colorbar;
set(clr2,'TickLabelInterpreter','latex');
clim([-1 1]);
xlim([0 500]);
xticks([0:100:500]);
ylim([0 500]);
yticks([0:100:500]);
pbaspect([1 1 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',18);
ax3=nexttile;
uimagesc(space_x,space_y,z);
box on;
axis xy;
colormap(gca,bluewhitered(256));
clr3=colorbar;
set(clr3,'TickLabelInterpreter','latex');
clim([-1 1]);
xlim([0 500]);
xticks([0:100:500]);
ylim([0 500]);
yticks([0:100:500]);
pbaspect([1 1 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',18);
set(gcf,'color','white');
set(gca,'Units','normalized');
set(u1,'Units','Inches');
posu1=get(u1,'Position');
set(u1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[posu1(3),posu1(4)]);
I have tried to add "gca" to the colormap() environment, as suggested in the discussions of the function, but it does not seem to do the job.
Any ideas?

採用された回答

DGM
DGM 2024 年 6 月 4 日
Unlike other map generators, bluewhitered() depends on the caxis of the current axes. You need to generate the map after you set caxis. If your subplots have different caxis symmetry about 0, then you must regenerate the map each time.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxes Appearance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by