Bluewhitered function in tiledlayout environment
2 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
DGM
on 4 Jun 2024
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 Comments
More Answers (0)
See Also
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!