change scale for colorbar

46 次查看(过去 30 天)
b.m.n n
b.m.n n 2019-11-27
编辑: Adam Danz 2019-11-30
Hello, can anyone help ,i will appreciate it very much.
I have three-figure with three different scale colorbar
I want to put one scale bar to them from min value to the max value how can I do that(one colorbar for 3 figure)
greetings to you all

回答(2 个)

ME
ME 2019-11-27
Have you tried looking at the below link - seems like that might do what you want

Adam Danz
Adam Danz 2019-11-27
编辑:Adam Danz 2019-11-27
You can set the color range of each subplot to be equal and then add a colorbar only to one of the plots. Then change the colorbar position.
Where ax is an axis handle and [min,max] is your color range.
  2 个评论
ME
ME 2019-11-27
This is fine but surely it would make the subfigure to which it is applied a smaller window than the others?
Adam Danz
Adam Danz 2019-11-27
编辑:Adam Danz 2019-11-30
By default, yes. That's why my answer suggests to change the colorbar position which would change the subplot back to it's standard size. Here's a demo for you to run
figure()
h = arrayfun(@(i)subplot(1,3,i),1:3);
cb = colorbar(h(end))
% After executing this line below, subplots will be same size.
cb.Position(1) = .93

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by