Deleting legends from subplot

154 views (last 30 days)
I have many figures. Each figure have 2 graphs. I want to delete legends in 2 graphs.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 27 Mar 2016
Edited: Azzi Abdelmalek on 27 Mar 2016
Look at this exampe
subplot(1,2,1);
plot(1:10)
legend('aa')
subplot(1,2,2);
plot(sin(1:10))
legend('bb')
%---delete the legend-------------
s=findobj('type','legend')
delete(s)
  3 Comments
RUBINEI DORNELES MACHADO
RUBINEI DORNELES MACHADO on 3 May 2020
Hi ... if you need delete specific legend in position x:
lgd.String(x)=[ ];
;)

Sign in to comment.

More Answers (1)

MHN
MHN on 27 Mar 2016
Edited: MHN on 27 Mar 2016
Open your figure and type in the command line:
legend('hide')
If you have many figures, put this in a loop and save the figure after hiding the legend.

Community Treasure Hunt

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

Start Hunting!