Info

This question is closed. Reopen it to edit or answer.

Switching from matlab 2013b version to 2020b version. Legend command with line handles

1 view (last 30 days)
hello All i switched from old 2013b matlab version to new 2020b matlab version.
In my existing scripts written originally in 2013b
now i think some issue with legend comand (legend on plots identified by handles), ill try to explain
Earlier (2013b),
ep_hdl=plot(0,0,'Visible','off','Color','k');
hleg2=legend([ep_hdl,ep_hd2], {'legend_name1','legend_name2'});
%ep_hd1 and ep_hd2 are line handles
here hleg2 used to return a handle of type double and below line i.e. leg_line used to contain line handles for both line
leg_line=findobj(hleg2,'type','Line');
Now in 2020b,
%when i use same code my leg_line is empty
leg_line=findobj(hleg2,'type','Line');
  2 Comments
Rik
Rik on 8 Sep 2021
So this code was essentially retrieving the plot handles? That seems a strange way to do it, and I don't really see a good reason why this behavior existed in HG1 (or at least R2013b).
Why don't you describe what you actually want? That way you can keep focussed on reproducing the intended effect, instead of trying to fix single lines of code.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!