How to find the actual length or xlabel coordinates in matlab

I use the following code to find the position of xlabel in a matlab figure.

xlabel('X'); get(get(gca,'XLabel'),'Position'); 

which gives me some coordinates (0.4981 -0.0669 1.0001). I think the coordinate is just the position of the top left label. So, how do I find the anchor for the label if I only know the fonts?

+4
source share
1 answer

Text objects have the "Extent" property:

Power

Position and size of the text. A four-element vector that determines the size and position of a text string:

 [left,bottom,width,height] 

If the Units property is data (default), the x- and y-coordinates of the lower left corner of the text are to the left and bottom.

For all other unit values, there is a distance from the lower left corner of the axes to the left and bottom. Set the rectangle to the lower left corner of the text. width and height are dimensions Extreme rectangle. All measurements are indicated in units indicated by property units.

+6
source

Source: https://habr.com/ru/post/1438264/


All Articles