Function like text() but with auto placement like legend?
81 views (last 30 days)
Does such a function exist which simply addes some text to a plot, without having specify the x/y location, and without also adding a line/marker graphic?
In other words, I am looking for a function which has output like text() (i.e., no other graphics, like legend() has), but which has the ability to intelligently place the text object, as in legend(), i.e.
dpb on 3 May 2017
Edited: dpb on 3 May 2017
No, altho I can guess the desire...would be kind of a nice touch if Matlab could/would automagically locate a desirable place to place a label for a line label, etc., without having to compute it. It's sometimes difficult to know programmatically where to place it so doesn't obstruct the already existing information on the axes.
Only thing I can think of at the moment is there are the 'best'|'bestoutside' values for the 'Location' property in legend but I don't think there are any other user functions with similar abilities. Some of the CurveFitting tools may label stuff, I'm not sure??? but those are applications, not user functions.
What the hey, submit an enhancement request...
PS. I didn't search but there's always a possibility somebody else has had the similar yen and has written/uploaded a solution on File Exchange.
More Answers (4)
Walter Roberson on 3 May 2017
In the case where you need only a single such item per axes:
h = line(nan, nan, 'Color', 'none');
legend(h, 'Your Message Here', 'Location', ....)
IT Department on 3 Jan 2020
There is a function in the Matlab File Exchange that addresses this issue.