GUI - position axis label possible?
4 次查看(过去 30 天)
显示 更早的评论
Good day everyone,
I'm having little place on my gui to make the axis label visible. I could of cause resize the plot but I really don't want to, everything is well structured. So is there a way i can position the x label? My idea was to delete the zero of the xlim and then position down the label. I don't know how promising this idea is. Do you know of some better options? I considered adding a *.svg with the axis symbol but that is stupid i guess.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162762/image.png)
Thanks for your help. Regards
0 个评论
回答(1 个)
dpb
2017-4-9
编辑:dpb
2017-4-12
Not certain what you want labelled where but xlabel by default will be at the midpoint of the axes to which it belongs and below the associated tick labels if shown or at the edge of the axis line if ticks aren't present.
But, it's just a text object; save the handle created and then you can modify the 'Position' property as desired.
To write text to arbitrary location(s ), use...wait a minute, drum roll, please!... text!!! :)
May want to use a fixed dimension for the 'position' property rather than the default 'Data' units so the position can be located relative to the actual figure rather than being scaled by the data values if they change...
But, if you know where the position is supposed to be initially, you can still use xlabel if want with the 'Position' vector as
xlabel('This is X','Position',[xpos ypos zpos])
but at that point may as well just revert to text form the beginning it would seem...it's the same animal underneath just which syntax is more useful is your call I think. Altho note that the 'Position' property is a three-vector where z=0 for a 2D plot; it still must be given. OTOH, the text interface just uses the x-, y- coordinates. Just a minor detail but can't overlook.
ADDENDUM
While it's been long time now with no response must presume got this worked out or gave up one, I'll note one way to work out this kind of thing would be to draw the gui and add the proposed xlabel text with default position and then use the edit tools to move it to desired position. Then you can query what that position vector is and use that to automagically create the figure in the code. "Cheating" is ok in such circumstances... :)
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!