Remove legend items from Figure
古いコメントを表示
In the figure, how to remove the item "aa" from the legennd without changing the shape of other items?
PointStyle = {'kp-', ...
'LineWidth', 1,...
'MarkerEdgeColor', 'k',...
'MarkerFaceColor', [0 0 .8],...
'MarkerSize',9};
plot(Points, PointStyle{:});
hold on
dataStyle = {'Marker','o', ...
'LineWidth', 1,...
'MarkerEdgeColor', [.8 0.4 0.2],...
'MarkerFaceColor', [1 .6 0.2],...
'MarkerSize',7};
plot(data, dataStyle{:});
if n <=3
%toDO
else
legend_str = {'aa','bb','cc'};
legend(legend_str, 'Fontsize',10,'Location', 'southoutside', 'Orientation','horizontal');
end

if n <=3
%toDO
else
legend_str = {'aa','bb','cc'};
legend(legend_str{2}, legend_str{3}, 'Fontsize',10,'Location', 'southoutside', 'Orientation','horizontal');
end
The shape of third item "cc" is changed:

3 件のコメント
madhan ravi
2019 年 1 月 25 日
https://www.mathworks.com/help/matlab/ref/legend.html#bu_sz6u-1 - create a handle for the plot command and follow the instruction in the given link
shdotcom shdotcom
2019 年 1 月 25 日
編集済み: shdotcom shdotcom
2019 年 1 月 25 日
madhan ravi
2019 年 1 月 25 日
Ok see this example , see if this is what you want:
plot(1:10,'-*r')
hold on
plot(2*(1:10),'-vg')
plot(3*(1:10),'-ob')
h=get(gca,'Children'); % grab all the axes handles at once
legendstr={'aa','bb','cc'};
legend(h([1 3]),legendstr{[1 3]}) % see the second label is skipped withoud changing shape
hold off
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で PX4 Autopilots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!