How to change width of bottom colorbar keeping the title
2 views (last 30 days)
Show older comments
Hey,
I want to change the width of the colorbar. Matlab suggest to
ax = gca;
axpos = ax.Position;
cpos = cb.Position;
cpos(4) = 0.5*cpos(4);
cb.Position = cpos;
ax.Position = axpos;
It basically works but I had to change the height of the colorbar. I used:
cpos(2) = cpos(2)+0.12;
Unfortunately, doing so makes me loose my figure title. Does anyone know how to keep the titel? I use Matlab 2015b. In my code I change the figure Position and I use the scatter function for plotting. Here is an extract of my code:
figure('Position', Position);
scatter(x,z,size,log10(Value),'s','filled');
set(gca, 'FontSize',fs); set(gca,'YDir','reverse');
set(gca,'XLim',[0 length]); set(gca,'YLim',[0 ylim]);
set(gca,'XAxisLocation','top')
cb=colorbar('location','southoutside');
ax = gca; axpos = ax.Position; cpos = cb.Position; cpos(4) = 0.5*cpos(4); cpos(2) = cpos(2)+0.12;
cb.Position = cpos; ax.Position = axpos;
title(ti,'FontSize',ts);
I hope anyone can help the very thick colorbar looks quite bad in some plots... Thank you!
0 Comments
Answers (2)
KSSV
on 19 Jul 2016
position vector is 1x4 where pos(1),pos(2) gives the origin where color begins. Try to push colorbar down by moving pos(2) downwards.
pos(2) = pos(2)-dy...where dy is fraction you want to push colorbar down...
See Also
Categories
Find more on 2-D and 3-D Plots 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!