我想改变图例的顺序。
见图。我希望序列是:绿色和data2
、蓝色和data3
、 黑色和data4
、 红色和data1
.
有人能给个demo吗?
![enter image description here](https://i.stack.imgur.com/hPvrh.png)
更改将图添加到图中的顺序,然后调用legend
通常情况下。应该可以做到这一点。
您也可以按如下方式进行。首先获取各个图的句柄:
h1 = plot(1:5);
hold on
h2 = plot(11:15, 'r');
然后打电话legend
指定顺序:
legend([h1 h2],'plot1','plot2')
or
legend([h2 h1],'plot2','plot1')
![enter image description here](https://i.stack.imgur.com/FUGiK.png)
![enter image description here](https://i.stack.imgur.com/z69O3.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)