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!)
h=[p1{1};p1{2};p1{3};p1{4};p1{5};p1{6};p1{7};p2{1};p2{2};p2{3};p2{4};p2{5};p2{6};p2{7};p3{1};p3{2};p3{3};p3{4};p3{5};p3{6};p3{7};p4{1};p4{2};p4{3};p4{4};p4{5};p4{6};p4{7};o1;o2;o3;o4];
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)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!