How can I lock my repositioned colorbar to the rest of my figure?
5 views (last 30 days)
Hi, I have produced a script to construct a contour plot with a colour bar within the plot itself. However when I change the size of the figure window the colour bar does not scale with it. Is there a way to get the colour bar to scale with the rest of the figure? Scipt:
xlabel('Distance upstream from Blackrock (m)');
Adam on 8 Oct 2015
set( c, 'units', 'normalized' )
after you have positioned it in points if that is your preferred method is the usual way to achieve a resizing object when the figure resizes, but it doesn't always yield the kind of resizing you want and I haven't tried it with colourbars.
Otherwise you may need to program a SizeChangedFcn callback for your figure in which you keep doing the new positioning maths yourself based on the current figure size or axes position or whatever you want to base it off.
Alternatively you could try the GUI Layout toolbox in the File Exchange, but that has a learning curve, especially for objects like colourbars.