MATLAB Answers

How can I get the extent (bounding box) of the legend on a plot?

1 view (last 30 days)
RonE
RonE on 11 Jan 2021
Commented: Mario Malic on 11 Jan 2021
How can I get the extent (bounding box) of the legend on a plot? For example, can get the extent of a text label like this:
h = text(x, y, "hello");
extent = get(h, 'extent');
I am trying to place text labels where they do not overlap with objects on the plot.
Thanks
Ron
  3 Comments
Mario Malic
Mario Malic on 11 Jan 2021
These numbers are relative to the axes parent frame. Last two numbers of legend's position property denote width and height relative to the axes border. First two being the distance between bottom-left corner of axes and bottom-left starting point of legend.
To get the coordinates, multiply the appropriate position properties of axes and legend.

Sign in to comment.

Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!