How to reduce the size of legend in a fig file?

8 views (last 30 days)
I have a MATLAB figure "abc.fig". The size of the legend is very large and has covered the graphs. I want to reduce its size and change its location. How can I do it? I applied the right click options but in vain.
  2 Comments
Sadiq Akbar
Sadiq Akbar on 20 Oct 2022
Thanks for your kind response dear Rik. The file is attached herewith.And the code is given below:
clear all
clc
x=[10 15 20 25 30 35 40];
y1=[0.48 0.31 0.2 0.16 0.15 0.14 0.14];%Purple
y2=[0.46 0.21 0.13 0.08 0.07 0.06 0.06];% Orange
y3=[0.42 0.19 0.14 0.08 0.07 0.06 0.06];% Yellow
y4=[0.38 0.19 0.14 0.12 0.099 0.08 0.08];% Blue
y5=[0.3052 0.1660 0.0844 0.0629 0.0570 0.0365 0.019];% My graph
y6=[0.24 0.13 0.06 0.04 0.02 0.01 0.009];
Purple=[0.4940, 0.1840, 0.5560];
semilogy(x,y1,'o-','color',Purple,'linewidth',2,'MarkerSize',7)
hold
Current plot held
Red=[0.8500, 0.3250, 0.0980];
semilogy(x,y2,'-','color',Red,'linewidth',2,'MarkerSize',7)
yellow=[0.9290, 0.6940, 0.1250];
semilogy(x,y3,'x-','color',yellow,'linewidth',2,'MarkerSize',9)
blue=[0.3010, 0.7450, 0.9330];
semilogy(x,y4,'v-','color',blue,'linewidth',2,'MarkerSize',7)
semilogy(x,y5,'g','linewidth',2);
semilogy(x,CRLB,'k--','linewidth',2);
Unrecognized function or variable 'CRLB'.
xlabel('Signal to Noise Ratio')
ylabel('Root Mean Sqaure Error (RMSE)')
title('RMSE vs SNR with N=10')
grid on
legend('Separate Learning Methodology based','First Principle based Method','Orthogonal Moving Machine Method','Direct and Indirect Method','FPA','Clever Root based Large byproduct')

Sign in to comment.

Answers (1)

Fabio Freschi
Fabio Freschi on 20 Oct 2022
You can try playing with the 'location' optional input, for example using
legend('blabla1','blabla2','Location','bestoutside')
Many options are available (check out this link)
  3 Comments
Sadiq Akbar
Sadiq Akbar on 20 Oct 2022
Thank you very much dear Fabio Freschi for your guiadance. Yes you are right that decreasing the font size seems bad. Your above code is very good. But since I reduce the size of the figure, so with that the legend area becomes large abd covers the graphs. With your code, the legend goes down and its very good but since I reduce the size of theb figure window so it seems very strnage to me.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!