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

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'));

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