position of axis label

조회 수: 35 (최근 30일)
Ray Lee
Ray Lee 2019년 12월 29일
편집: dpb 2019년 12월 31일
When changing the axis limits, the location of the axis label string remains at the center of the axis. But if I moved the label position manually, the label string location is binded to a value. When changing the axis limits, the label string moves away from the axis center.
I checked the properties of the label:
>> ax.XLabel.get
BackgroundColor: 'none'
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
Children: [0×0 GraphicsPlaceholder]
Clipping: 'off'
Color: [1 1 0.8000]
CreateFcn: ''
DeleteFcn: ''
EdgeColor: 'none'
Editing: 'off'
Extent: [216.0002 -79.8522 0 0]
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 8.2500
FontSmoothing: 'on'
FontUnits: 'points'
FontWeight: 'bold'
HandleVisibility: 'off'
HitTest: 'on'
HorizontalAlignment: 'center'
Interpreter: 'tex'
Interruptible: 'on'
LineStyle: '-'
LineWidth: 0.5000
Margin: 3
Parent: [1×1 Axes]
PickableParts: 'visible'
Position: [216.0002 -79.8522 1]
Rotation: 0
Selected: 'off'
SelectionHighlight: 'on'
String: ''
Tag: ''
Type: 'text'
UIContextMenu: [0×0 GraphicsPlaceholder]
Units: 'data'
UserData: []
VerticalAlignment: 'top'
Visible: 'on'
There is no property to set to make the positioning automatic.
How can I recover the automatic positioning?

채택된 답변

dpb
dpb 2019년 12월 29일
편집: dpb 2019년 12월 31일
"There is no property to set to make the positioning automatic."
Ah, but there is...unfortunately, it's another of those frustrating things TMW hid from the user...but, thanks to being able to find out about such via <Yair's undocumented handles function>,
hAx.XLabel.PositionMode='auto';
will do the trick. When you position the label the value gets set to ' manual' which turns off the automagic recomputation of the center position. Fortunately, the other property values remain unchanged so don't have to do more than just toggle the mode indicator.
It's surely unfortunate TMW chose to hide so many of these really useful and needed properties and have no indication in the documentation there are such things available. :(

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by