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

╄→гoц情女王★ 提交于 2020-01-04 02:48:29

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/26704815/how-to-create-one-common-legend-for-4-subplots-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!