How can we include colorbar in current axis position.?
3 views (last 30 days)
Show older comments
I used the function given in
for calculating the current axis position of the figure. I used "TightInset" property of original axis position to include xlabel, ylabel and title in the current axis position. However i am unable to find a way to include colorbar.
Attached is the picture, essentially i want to include colorbar also in the boundary denoted by black.
Also attached is the code
figure
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
set(gca, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
xlim([0 2]);
ylim([0 1]);
xlabel('test','FontSize',30,'Interpreter','latex');
ylabel('test','FontSize',30,'Interpreter','latex');
title('test','FontSize',30,'Interpreter','latex');
set(gca, 'TickLabelInterpreter','latex','FontSize',30);
colorbar
c = colorbar;
c.TickLabelInterpreter = 'latex';
c.Label.FontSize = 30;
inset = get(gca,'TightInset');
axis equal
xlim([0 2]);
ylim([0 1]);
box on
pos1 = get(gca, 'position');
annotation('rectangle', pos1, 'edgecolor', 'b', 'linestyle', '--');
pos2 = plotboxpos(gca);
annotation('rectangle', pos2, 'edgecolor', 'r', 'linestyle', '-.');
posm = [pos2(1)-inset(1), pos2(2)-inset(2), pos2(3)+inset(1)+inset(3),pos2(4)+inset(2)+inset(4)];
annotation('rectangle', posm, 'edgecolor', 'k', 'linestyle', '-.');
0 Comments
Answers (0)
See Also
Categories
Find more on Colorbar 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!