隐藏图例中的行 [英] Hide line from legend
问题描述
我需要从图例中隐藏4行.我使用的是
创建图例时,
I need to hide 4 lines from the legend. I'm using shadedErrorBar so I have 3 line for a sigle group (mean, upper edge of standard deviation and bottom edge) and if i use the classic code legend('line1','line2,'...)
I'll have 3 label. I want in the legend only the mean for each group.
I have 2 groups.
shadedErrorBar(x,y1,e1);
shadedErrorBar(x,y2,e2);
y1
and y2
are my means, while e1
and e2
standard deviations.
I think I should use IconDisplayStyle but I don't understand how. I read this http://it.mathworks.com/help/matlab/creating_plots/controlling-legends.html but is like hide a plot
to hide a line. With shadedErrorBar I have a graph with 3 plot on it for each group.
When you create the legend, you can specify only the plot objects that you would like to create legend entries for. The output of shadedErrorBars
is a struct containing all of the plot objects so you can use these to grab the patch objects and create legend entries for only those.
h1 = shadedErrorBar(linspace(1,10), linspace(1,10), linspace(0,1));
hold on
h2 = shadedErrorBar(linspace(1,10), linspace(1,20), linspace(1,0));
legend([h1.patch, h2.patch], {'Item1', 'Item2'})
这篇关于隐藏图例中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!