MATLAB Answers

How to adjust size of the legend in large figures?

1 view (last 30 days)
Joshitha R
Joshitha R on 10 Jul 2021
Edited: Ive J on 11 Jul 2021
I have a graph with multiple curves (32 of them!)
a=legend(h,'Ours s1 (Rank 4)','Ours s1 (Rank 8)','Ours s1 (Rank 16)','Ours s1 (Rank 28)','Ours s1 (Rank 44)','Ours s1 (Rank 52)','Ours s1 (Rank 60)','Ours s2 (Rank 4)','Ours s2 (Rank 8)','Ours s2 (Rank 16)','Ours s2 (Rank 28)','Ours s2 (Rank 44)','Ours s2 (Rank 52)','Ours s2 (Rank 60)','Ours s3 (Rank 4)','Ours s3 (Rank 8)','Ours s3 (Rank 16)','Ours s3 (Rank 28)','Ours s3 (Rank 44)','Ours s3 (Rank 52)','Ours s3 (Rank 60)','Ours s4 (Rank 4)','Ours s4 (Rank 8)','Ours s4 (Rank 16)','Ours s4 (Rank 28)','Ours s4 (Rank 44)','Ours s4 (Rank 52)','Ours s4 (Rank 60)','Dib et al. s1','Dib et al. s2','Dib et al. s3','Dib et al. s4','Location','Best');
After plotting the figure, I use the 'saveas' function to save the plot as an image
saveas(figure(4),'./latest plots/OURS_BIKES_YUVPSNR_C4.png');
I am not satisfied with the way the output is saved.
Any alternatives?

Accepted Answer

Ive J
Ive J on 11 Jul 2021
Edited: Ive J on 11 Jul 2021
Try NumColumns property:
plot(randn(400, 40), randn(400, 40), '.-')
legObj = legend(gca, 'NumColumns', 2);

More Answers (0)




Community Treasure Hunt

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

Start Hunting!