matlab图例叉号
时间: 2023-11-11 20:58:45 浏览: 117
matlab 分叉图
4星 · 用户满意度95%
要在 MATLAB 图例中添加叉号,可以使用以下代码:
```
h = plot(1:10);
hold on
g = plot(10:-1:1);
legend([h,g],{'Line 1','Line 2','Line 1 with X','Line 2 with X'})
set(get(get(h,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
set(get(get(g,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
hAnnotation = get(h,'Annotation');
hLegendEntry = get(hAnnotation','LegendInformation');
set(hLegendEntry,'IconDisplayStyle','x');
gAnnotation = get(g,'Annotation');
gLegendEntry = get(gAnnotation','LegendInformation');
set(gLegendEntry,'IconDisplayStyle','x');
```
这将在图例中添加一个叉号,表示每个线条的末尾。
阅读全文