switching from 2013b VERSION TO 2020. Accessing figure handle from plot command
3 views (last 30 days)
Show older comments
hello all ,
I just switched to 2020 version from 2013b.
when i was checking where 2013 scripts are compatible with 2020, i found that
ep_hdl=plot(0,0,'Visible','off','Color','k');
above code gave me figure handle in 2013b, but not in 2020.
what should i do to get results same as 2013b version so that rest of my code stays intact.
Any help would be helpful.
Thanks in Advance
Answers (2)
Jan
on 7 Sep 2021
Edited: Jan
on 7 Sep 2021
No, this did not reply a figure handle in R2013b:
ep_hdl=plot(0,0,'Visible','off','Color','k');
The plot command replied a line handle and it still does in R2020.
With the HG1 interface of R2013b the line handle was a double as all GUI handles. With HG2 the handles are specific types.
If this line handle is used as handle to this line only and the code does not assume, that it a double, the existing code should run without changes. So please post the part of the code, which is failing.
3 Comments
Jan
on 8 Sep 2021
Edited: Jan
on 8 Sep 2021
legend is one of the commands with the most changes between the Matlab versions. Some changes are useful, many are not compatible. What do you want to do with the line handles? See:
- https://www.mathworks.com/matlabcentral/fileexchange/58914-resizelegend-varargin
- https://www.mathworks.com/matlabcentral/answers/304258-retrieve-legend-handles-and-text
- https://www.mathworks.com/matlabcentral/answers/95161-how-can-i-modify-the-lengh-of-the-lines-in-a-legend
In HG1 the handles of the legend's line objects have been replied as further output arguments. I've used them to attach callbacks to let the user move a line to the top by clicking in the legend, if the line is hidden behind others. In another case I've removed markers from the legend, because they are useful in a diagram only.
I have the need to write code, which runs under R6.5, 2009a and 2018b. I found many workarounds, e.g. creating my own graphic handles as pseudo-object using structs, and created an own string library for the useful commands: contains, startsWith etc. But legend is a severe problem, because the feature are changing too rapidly and there is no chance to get a stable set of methods for such tweaks as mentioned above.
My solution is not to use the legend command for productive work.
I'm very happy that only unique,union,intersect,setdiff and strncmp have a comparably high variability between the Matlab versions.
Steven Lord
on 25 Oct 2021
Prior to the major graphics changes in release R2014b legend created an axes. As of release R2014b it now creates a legend object instead. See pages 1-29 and 1-30 in this PDF documentation for more information.
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!