comparison scripts/plot/legend.m @ 13936:bfaacd5e7379

Bug fix (#34901). Allow legend options to be specified. Modify demo.
author Ben Abbott <bpabbott@mac.com>
date Fri, 25 Nov 2011 23:44:44 -0500
parents 984359717d71
children 1ab3062df1ae
comparison
equal deleted inserted replaced
13935:e48e8253ce58 13936:bfaacd5e7379
401 for j = 1 : length (hgkids) 401 for j = 1 : length (hgkids)
402 hgobj = get (hgkids (j)); 402 hgobj = get (hgkids (j));
403 if (isfield (hgobj, "displayname") 403 if (isfield (hgobj, "displayname")
404 && ! isempty (hgobj.displayname)) 404 && ! isempty (hgobj.displayname))
405 hplots = [hplots, hgkids(j)]; 405 hplots = [hplots, hgkids(j)];
406 text_strings = {text_strings{:}, hbobj.displayname}; 406 text_strings = {text_strings{:}, hgobj.displayname};
407 break; 407 break;
408 endif 408 endif
409 endfor 409 endfor
410 else 410 else
411 if (! isempty (get (kids (k), "displayname"))) 411 if (! isempty (get (kids (k), "displayname")))
1081 1081
1082 %!demo 1082 %!demo
1083 %! clf 1083 %! clf
1084 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; 1084 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382];
1085 %! bar (rand_2x3_data1); 1085 %! bar (rand_2x3_data1);
1086 %! ylim ([0 1.2]); 1086 %! ylim ([0 1.0]);
1087 %! legend ({"1st Bar", "2nd Bar", "3rd Bar"}); 1087 %! legend ({"1st Bar", "2nd Bar", "3rd Bar"});
1088 1088
1089 %!demo 1089 %!demo
1090 %! clf 1090 %! clf
1091 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531]; 1091 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531];
1092 %! bar (rand_2x3_data2); 1092 %! bar (rand_2x3_data2);
1093 %! ylim ([0 1.2]); 1093 %! ylim ([0 1.2]);
1094 %! legend ("1st Bar", "2nd Bar", "3rd Bar"); 1094 %! legend ("1st Bar", "2nd Bar", "3rd Bar");
1095 %! legend right
1095 1096
1096 %!demo 1097 %!demo
1097 %! clf 1098 %! clf
1098 %! x = 0:0.1:7; 1099 %! x = 0:0.1:7;
1099 %! h = plot (x, sin(x), x, cos(x), x, sin(x.^2/10), x, cos(x.^2/10)); 1100 %! h = plot (x, sin(x), x, cos(x), x, sin(x.^2/10), x, cos(x.^2/10));