MATLAB: How to get handles of a legend that was automatically generated

axisfigurelegendMATLAB

I am trying to move an automatically generated (did not create command like: lgd=legend(…)) legend in a subplot.
How to access that legend? so that I can use lgd.location=best.
Also, legend moving sometimes disturbs axis extents, how to avoid that? ————————
Edit1: I am using following code to generate plot that generates automatic legends:
parallelcoords(P1to5,'Group',...
Group1to5,'Labels',Labels1to5);

Best Answer

H = findobj('type','legend')
H.Location = 'best'