Size of color bar including labels in Matlab R2014b [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 07:53:27

问题


How do I find out how much space a color bar takes up using Matlab R2014b? I need to know the total size including all labels, but if I do

c = colorbar;
get(c,'TightInset');

I get the error message

Error using matlab.graphics.illustration.ColorBar/get
There is no TightInset property on the ColorBar class.

The same holds for OuterPosition. Apparently, these properties are no longer supported for the ColorBar class in R2014b.


回答1:


Try:

original = get(c, 'Position')
set(c, 'Position', [original(1) original(2)*0.5, original(3), original(4)*0.5])

The handle c contains a 'Position' property, same as many graphics handles. Look up the documentation to understand it more fully. To verify that this translates the position of colorbar title and labels too, execute the following:

set(get(c, 'YLabel'), 'String', {'a', 'b', 'c'})     % Arbitrary Labels
set(get(c, 'Title'), 'String', {'Colorbar Title'});  % Arbitrary Title
set(c, 'Position', [original])                       % Resize back to original and observe!


来源:https://stackoverflow.com/questions/26313400/size-of-color-bar-including-labels-in-matlab-r2014b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!