How to set the size of a colorbar in a subplot?

20 views (last 30 days)
Sophie Pailot
Sophie Pailot on 28 Oct 2021
Commented: dpb on 29 Oct 2021
I am creating a (1,3) subplot and want to put one colorbar on the right.
I have already used previously suggested answers in order to move it the way I wanted with the 'Position' matrix
The problem is that when changing the size of the figure window, the colorbar doesn't follow these changes as the subplots.
More precisely, the width and the x bottom left keep an acceptable ratio but not the height or the y bottom right
Typically, picture 1 is good (and done manually) and then picture 2 is not so good anymore, just after a few adjustements to the figure window size)
This is the code I am using
colorbar('Position', [0.95 0.25 0.02 0.535])
Would there be a way to fix the length of the color bar to adjust to the size of the subplots at all time ?
Thanks a lot
dpb on 29 Oct 2021
You'll probably have more luck in somebody trying to play with your issue if you'll attach a working minimal example to produce a sample figure to work on. It's much simpler to have the starting point already created rather than trying to first create your working conditions.

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!