Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create one common legend for 4 subplots in MATLAB?

How can I create one common legend for 4 subplots in MATLAB, like this:

enter image description here

like image 741
ahammadz Avatar asked Dec 09 '25 21:12

ahammadz


1 Answers

Quick and dirty:

hSub = subplot(3,1,1); plot(1,1,1,1,1,1,1,1);
hLegend = legend('hello','i','am','legend');

subplot(3,2,3), plot(10:-1:1); subplot(3,2,4), plot(1:100);
subplot(3,2,5), stem(1:10); subplot(3,2,6), plot(randn(1,100))

set(hLegend, 'position', get(hSub, 'position'));

enter image description here

like image 156
Akshay Rao Avatar answered Dec 11 '25 12:12

Akshay Rao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!