Cannot find colorbar resize function

조회 수: 2 (최근 30일)
Guillaume
Guillaume 2023년 9월 13일
답변: Guillaume 2023년 9월 27일
Hello there. Can you access the resize function of a colorbar ? Or implement the same behavior for other graphic components ?
At least I don't get it from the properties.
  • "Units" is 'normalized'
  • There's no "OuterPosition" property
  • "Layout" is empty
  • "Parent" is the figure
  • The "Position" property changes when you change the window (or frame) size
I didn't find something relevant in related axes either.
But I like how it behaves, and I would like other axes to behave the same. Beyond keeping a relevant position and size, it is performant. I mean it doesn't heavily load CPU or GPU when resizing the window. And I'm struggling with that in general. Using Layouts or figure SizeChangedFcn is not convenient for many reasons, but not the topic here...

채택된 답변

Guillaume
Guillaume 2023년 9월 27일
I actually found... Colorbars are simply using listeners to position-related properties of axes. I thought axes properties like 'Position' or 'OuterPosition' couldn't be SetObervable or GetObervable, they actually are.
fig = figure;
ax = axes(fig);
cb = colorbar(ax);
cb_axlisteners = ax.AutoListeners__

추가 답변 (1개)

Rishi
Rishi 2023년 9월 25일
Hi Guillaume,
I understand you want to access the ‘resize’ function of ‘colorbar’ to change its size. There is no function called ‘resize’ for a ‘colorbar’, and instead, to change its size and location, you can use the ‘Position’ property.
It is specified as a four element vector of the form [left, bottom, width, height], where ‘left’ and ‘bottom’ specify the distance of the bottom-left corner of the ‘colorbar’ to the bottom-left corner of the figure. The ‘width’ and ‘height’ properties specify the dimensions of the ‘colorbar’.
You can find more information about ‘colorbar’ properties in the below documentation:
Hope this helps.
Regards,
Rishi Shrimal
  댓글 수: 2
Guillaume
Guillaume 2023년 9월 25일
Hi Rishi, and thank you for your feedback.
It's actually the other way. I don't want to change the resize behavior of a colorbar, I would like to "copy" it. I would like to create axes with similar resize behavior without using layouts.
Rishi
Rishi 2023년 9월 26일
Hi Guillaume,
I understand that you want a function that resizes ‘axes’ in a similar way like ‘Position’ resizes ‘colorbar’.
This can be done using the ‘OuterPosition’ function of axes. You can refer to the below documentation to know more about axes properties:
Regards,
Rishi Shrimal

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

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by