Cannot move or resize colorbar in tiledlayout

Hi everyone. I have a problem with the Colorbar and the tiledlayout function. Once I create a tiledlayout and create the colorbar for each axes it appears that i cannot manually move or resize the colorbar. The following warning appears:
Warning: Error updating ColorBar.
The reference object is invalid.
And then the colorbar places in the middle of the axes.
As an example, try out this:
tiledlayout(1,2);
ah(1)=nexttile(1); imagesc(rand(3,4));
ah(2)=nexttile(2); imagesc(rand(3,4));
cbh = colorobar(ah(2));
cbh.Position(4) = 0.5

댓글 수: 5

Sindar
Sindar 2020년 1월 20일
1) you have a typo in your example code (but not your actual) "colorobar" vs "colorbar"
2) it seems like it works despite giving a warning
Hi Sindar. Sorry for the typo. What do you mean with
"2) it seems like it works despite giving a warning"
Do you see the colorbar properly resized to half its height?
Sindar
Sindar 2020년 1월 20일
Ah, you're right. It moves the colorbar, but not how you want, and it doesn't update the position
Sindar
Sindar 2020년 1월 20일
The exact same behavior happens when you try to move/resize it in the GUI. That's a bad sign
jerry Lu
jerry Lu 2023년 12월 5일
did u solved that,i met same question like u

댓글을 달려면 로그인하십시오.

답변 (1개)

Edoardo Ferocino
Edoardo Ferocino 2020년 1월 20일

0 개 추천

Looking at the help I found at https://it.mathworks.com/help/matlab/ref/matlab.graphics.illustration.colorbar-properties.html#d117e181365 that "Setting this property has no effect when the parent container is a TiledChartLayout." referred to the Position property...
I wonder why MATLAB does not let me move the colorbar... I was glad they finally introduced some function for proper arranging axes withouth blank spaces... But this is a little bit annoying. I think I might return to the function subplot1

댓글 수: 1

Sindar
Sindar 2020년 1월 20일
Hopefully they'll improve it in later versions. I was also about to switch to TiledChartLayout. Thanks, now I know to wait until it's more a more complete option.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 1월 20일

댓글:

2023년 12월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by