MATLAB Answers

0

How to get handles of a legend that was automatically generated?

Asked by KJVKU999 on 26 Sep 2017
Latest activity Answered by Aiyush
on 23 Mar 2019
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);

  0 Comments

Sign in to comment.

Products

2 Answers

Answer by Jos (10584)
on 26 Sep 2017
 Accepted Answer

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

  1 Comment

Sign in to comment.


Answer by Aiyush
on 23 Mar 2019

This only works when you want to retrieve 1 legend. If there are multiple legends on a complex figure, and you want to modify let's say the font size of the 2nd legend, then this is more difficult.

  0 Comments

Sign in to comment.