MATLAB Answers

Change colorbar title position latex

12 views (last 30 days)
Hi,
In the attached figure, I would like to reposition the colorbar axis title to be along with colorbar. May I know how to change the psotion.
set(c,'String',['$','\omega','(1/s)','$'],'Interpreter','latex','fontsize',18);

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 19 Oct 2020
Try something like this
c = colorbar;
c.Title.String = '$\omega(1/s)$';
c.Title.Interpreter = 'latex';
c.Title.FontSize = 16;
c.Title.Units = 'data';
c.Title.Position(1:2) = [3.5 mean(c.Limits)]; % adjust value of 3.5 until you get correct horizontal position

  10 Comments

Show 7 older comments
Turbulence Analysis
Turbulence Analysis on 20 Oct 2020
Here is the values belongs to K = 2 in for loop, basically below code will work for this .. Bcoz my UU matrix is too big ( close to 1.5 gb)...
ax = gca;
colormap(jet);
imagesc(x,y,(New3));
xlabel('x(mm)','FontSize',20,'Interpreter','latex');
ylabel('y(mm)','FontSize',20,'Interpreter','latex');
set(gca,'TickLabelInterpreter','latex')
set(gca, 'FontSize', 24)
hold on;
ff = quiver (X', Y', (New3), (New4));
ff.Color='black';
ff.AutoScaleFactor=3;
set(gca, 'YDir','normal')
c = colorbar('FontSize',20,'TickLabelInterpreter', 'latex');
c.Title.String = '$ U(m/s)$';
c.Title.Interpreter = 'latex';
c.Title.FontSize = 16;
c.Title.Units = 'data';
c.Title.Position(1:2) = [3.5 mean(c.Limits)];
c.Title.Rotation = 90;
caxis ([-0.02 0.02]);
saveas(gcf, sprintf('UMode%d', k), 'bmp')
savefig(gcf, sprintf('UMode%d', k))
Turbulence Analysis
Turbulence Analysis on 20 Oct 2020
I sorted the issue. The caxis ([-0.02 0.02]); which is defined just after the c.Title.Rotation = 90; causes the problem, I have moved this to the top just after the imagesc(x,y,(New3));.
Hence, now the position of colorbar title is remains unaltered across all the images in for loop.
Thanks....

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by