我正在尝试将带有颜色条的图像绘图复制到另一个创建的图形上。我正在使用函数copyobj(H,p)
,但是我需要更改'Position'属性以使图像和颜色条的高度更高。
我的代码:
plotHeight = maxHeight/length(plots);
for i=1:length(plots)
if not(isempty(colorbars{length(plots)-(i-1)}))
objs = copyobj([plots(length(plots)-(i-1)),colorbars{length(plots)-(i-1)}], fignew);
pos = get(objs(1), 'Position');
disp(pos);
set(objs(1), 'Position', [pos(1) bottomOffset+(plotHeight*(i-1))+margin pos(3) plotHeight-(margin/2)]);
disp(get(objs(1), 'Position'));
poscb = get(objs(2), 'Position');
set(objs(2), 'Position', [poscb(1) bottomOffset+(plotHeight*(i-1))+margin poscb(3) plotHeight-(margin/2)]);
else
plt = copyobj(plots(length(plots)-(i-1)), fignew);
pos = get(plt, 'Position');
set(plt, 'Position', [pos(1) bottomOffset+(plotHeight*(i-1))+margin pos(3) plotHeight-(margin/2)]);
end
end
错误是将Imageplot和Colorbar复制到另一个图形后,set('Position')属性不起作用。如果我在设置后显示Position属性,则该值是正确的,但在该图上该图的高度错误。