Mercurial > hg > octave-nkf
comparison scripts/plot/legend.m @ 14245:4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
* contrast.m, axis.m, clabel.m, colorbar.m, comet.m, contour.m, contour3.m,
cylinder.m, daspect.m, errorbar.m, ezplot.m, fplot.m, grid.m, hold.m,
isosurface.m, legend.m, loglog.m, loglogerr.m, pareto.m, patch.m, pbaspect.m,
pie.m, pie3.m, plot3.m, plotmatrix.m, plotyy.m, quiver.m, quiver3.m,
rectangle.m, refreshdata.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m,
semilogy.m, semilogyerr.m, shading.m, stem.m, subplot.m, text.m, title.m,
trimesh.m, triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m,
uiputfile.m, waitbar.m, xlim.m, ylim.m, zlim.m: Use Matlab coding conventions
for demos so that compare plots scripts will function.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 22 Jan 2012 07:31:32 -0800 |
parents | 11949c9795a0 |
children | 4e6436a60b62 |
comparison
equal
deleted
inserted
replaced
14241:a52925666288 | 14245:4506eade9f04 |
---|---|
974 | 974 |
975 | 975 |
976 %!demo | 976 %!demo |
977 %! clf; | 977 %! clf; |
978 %! x = 0:1; | 978 %! x = 0:1; |
979 %! plot (x,x,";I am Blue;", x,2*x,";I am Green;", x,3*x,";I am Red;"); | 979 %! plot (x,x,';I am Blue;', x,2*x,';I am Green;', x,3*x,';I am Red;'); |
980 | 980 |
981 %!demo | 981 %!demo |
982 %! clf; | 982 %! clf; |
983 %! x = 0:1; | 983 %! x = 0:1; |
984 %! plot (x, x, ";\alpha;", | 984 %! plot (x, x, ';\alpha;', ... |
985 %! x, 2*x, ";\beta=2\alpha;", | 985 %! x, 2*x, ';\beta=2\alpha;', ... |
986 %! x, 3*x, ";\gamma=3\alpha;"); | 986 %! x, 3*x, ';\gamma=3\alpha;'); |
987 | 987 |
988 %!demo | 988 %!demo |
989 %! clf; | 989 %! clf; |
990 %! x = 0:1; | 990 %! x = 0:1; |
991 %! plot (x,x,";I am Blue;", x,2*x, x,3*x,";I am Red;"); | 991 %! plot (x,x,';I am Blue;', x,2*x, x,3*x,';I am Red;'); |
992 %! title ("Blue and Green keys, with Green missing"); | 992 %! title ('Blue and Green keys, with Green missing'); |
993 | 993 |
994 %!demo | 994 %!demo |
995 %! clf; | 995 %! clf; |
996 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); | 996 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
997 %! title ("incline is blue and decline is green"); | 997 %! title ('incline is blue and decline is green'); |
998 %! legend ({"I am blue", "I am green"}, "location", "east"); | 998 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
999 | 999 |
1000 %!demo | 1000 %!demo |
1001 %! clf; | 1001 %! clf; |
1002 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); | 1002 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
1003 %! title ("Legend is hidden") | 1003 %! title ('Legend is hidden') |
1004 %! legend ({"I am blue", "I am green"}, "location", "east"); | 1004 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
1005 %! legend hide; | 1005 %! legend hide; |
1006 | 1006 |
1007 %!demo | 1007 %!demo |
1008 %! clf; | 1008 %! clf; |
1009 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); | 1009 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
1010 %! title ("Legend with box on"); | 1010 %! title ('Legend with box on'); |
1011 %! legend ({"I am blue", "I am green"}, "location", "east"); | 1011 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
1012 %! legend boxon; | 1012 %! legend boxon; |
1013 | 1013 |
1014 %!demo | 1014 %!demo |
1015 %! clf; | 1015 %! clf; |
1016 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); | 1016 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
1017 %! title ("Legend with text to the right"); | 1017 %! title ('Legend with text to the right'); |
1018 %! legend ({"I am blue", "I am green"}, "location", "east"); | 1018 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
1019 %! legend right; | 1019 %! legend right; |
1020 | 1020 |
1021 %!demo | 1021 %!demo |
1022 %! clf; | 1022 %! clf; |
1023 %! plot (1:10, 1:10); | 1023 %! plot (1:10, 1:10); |
1024 %! title ("a very long label can sometimes cause problems"); | 1024 %! title ('a very long label can sometimes cause problems'); |
1025 %! legend ({"hello world"}, "location", "northeastoutside"); | 1025 %! legend ({'hello world'}, 'location', 'northeastoutside'); |
1026 | 1026 |
1027 %!demo | 1027 %!demo |
1028 %! clf; | 1028 %! clf; |
1029 %! plot (1:10, 1:10); | 1029 %! plot (1:10, 1:10); |
1030 %! title ("a very long label can sometimes cause problems"); | 1030 %! title ('a very long label can sometimes cause problems'); |
1031 %! legend ("hello world", "location", "northeastoutside"); | 1031 %! legend ('hello world', 'location', 'northeastoutside'); |
1032 | 1032 |
1033 %!demo | 1033 %!demo |
1034 %! clf; | 1034 %! clf; |
1035 %! labels = {}; | 1035 %! labels = {}; |
1036 %! colororder = get (gca, "colororder"); | 1036 %! colororder = get (gca, 'colororder'); |
1037 %! for i = 1:5 | 1037 %! for i = 1:5 |
1038 %! h = plot (1:100, i + rand(100,1)); hold on; | 1038 %! h = plot (1:100, i + rand(100,1)); hold on; |
1039 %! set (h, "color", colororder(i,:)); | 1039 %! set (h, 'color', colororder(i,:)); |
1040 %! labels = {labels{:}, cstrcat("Signal ", num2str (i))}; | 1040 %! labels = {labels{:}, cstrcat('Signal ', num2str (i))}; |
1041 %! endfor | 1041 %! end |
1042 %! hold off; | 1042 %! hold off; |
1043 %! title ("Signals with random offset and uniform noise"); | 1043 %! title ('Signals with random offset and uniform noise'); |
1044 %! xlabel ("Sample Nr [k]"); ylabel ("Amplitude [V]"); | 1044 %! xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]'); |
1045 %! legend (labels, "location", "southoutside"); | 1045 %! legend (labels, 'location', 'southoutside'); |
1046 %! legend ("boxon"); | 1046 %! legend ('boxon'); |
1047 | 1047 |
1048 %!demo | 1048 %!demo |
1049 %! clf; | 1049 %! clf; |
1050 %! labels = {}; | 1050 %! labels = {}; |
1051 %! colororder = get (gca, "colororder"); | 1051 %! colororder = get (gca, 'colororder'); |
1052 %! for i = 1:5 | 1052 %! for i = 1:5 |
1053 %! h = plot (1:100, i + rand (100,1)); hold on; | 1053 %! h = plot (1:100, i + rand (100,1)); hold on; |
1054 %! set (h, "color", colororder(i,:)); | 1054 %! set (h, 'color', colororder(i,:)); |
1055 %! labels = {labels{:}, cstrcat("Signal ", num2str (i))}; | 1055 %! labels = {labels{:}, cstrcat('Signal ', num2str (i))}; |
1056 %! endfor | 1056 %! end |
1057 %! hold off; | 1057 %! hold off; |
1058 %! title ("Signals with random offset and uniform noise"); | 1058 %! title ('Signals with random offset and uniform noise'); |
1059 %! xlabel ("Sample Nr [k]"); ylabel ("Amplitude [V]"); | 1059 %! xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]'); |
1060 %! legend (labels{:}, "location", "southoutside"); | 1060 %! legend (labels{:}, 'location', 'southoutside'); |
1061 %! legend ("boxon"); | 1061 %! legend ('boxon'); |
1062 | 1062 |
1063 %!demo | 1063 %!demo |
1064 %! clf; | 1064 %! clf; |
1065 %! x = linspace (0, 10); | 1065 %! x = linspace (0, 10); |
1066 %! plot (x, x); | 1066 %! plot (x, x); |
1067 %! hold on; | 1067 %! hold on; |
1068 %! stem (x, x.^2, 'g'); | 1068 %! stem (x, x.^2, 'g'); |
1069 %! legend ("linear"); | 1069 %! legend ('linear'); |
1070 %! hold off; | 1070 %! hold off; |
1071 | 1071 |
1072 %!demo | 1072 %!demo |
1073 %! clf; | 1073 %! clf; |
1074 %! x = linspace (0, 10); | 1074 %! x = linspace (0, 10); |
1075 %! plot (x, x, x, x.^2); | 1075 %! plot (x, x, x, x.^2); |
1076 %! legend ("linear"); | 1076 %! legend ('linear'); |
1077 | 1077 |
1078 %!demo | 1078 %!demo |
1079 %! clf; | 1079 %! clf; |
1080 %! x = linspace (0, 10); | 1080 %! x = linspace (0, 10); |
1081 %! plot (x, x, x, x.^2); | 1081 %! plot (x, x, x, x.^2); |
1082 %! legend ("linear", "quadratic"); | 1082 %! legend ('linear', 'quadratic'); |
1083 | 1083 |
1084 %!demo | 1084 %!demo |
1085 %! clf; | 1085 %! clf; |
1086 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; | 1086 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; |
1087 %! bar (rand_2x3_data1); | 1087 %! bar (rand_2x3_data1); |
1088 %! ylim ([0 1.0]); | 1088 %! ylim ([0 1.0]); |
1089 %! legend ({"1st Bar", "2nd Bar", "3rd Bar"}); | 1089 %! legend ({'1st Bar', '2nd Bar', '3rd Bar'}); |
1090 | 1090 |
1091 %!demo | 1091 %!demo |
1092 %! clf; | 1092 %! clf; |
1093 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531]; | 1093 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531]; |
1094 %! bar (rand_2x3_data2); | 1094 %! bar (rand_2x3_data2); |
1095 %! ylim ([0 1.2]); | 1095 %! ylim ([0 1.2]); |
1096 %! legend ("1st Bar", "2nd Bar", "3rd Bar"); | 1096 %! legend ('1st Bar', '2nd Bar', '3rd Bar'); |
1097 %! legend right; | 1097 %! legend right; |
1098 | 1098 |
1099 %!demo | 1099 %!demo |
1100 %! clf; | 1100 %! clf; |
1101 %! x = 0:0.1:7; | 1101 %! x = 0:0.1:7; |
1102 %! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10)); | 1102 %! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10)); |
1103 %! title ("Only the sin() objects have keylabels"); | 1103 %! title ('Only the sin() objects have keylabels'); |
1104 %! legend (h([1, 3]), {"sin(x)", "sin(x^2/10)"}, "location", "southwest"); | 1104 %! legend (h([1, 3]), {'sin(x)', 'sin(x^2/10)'}, 'location', 'southwest'); |
1105 | 1105 |
1106 %!demo | 1106 %!demo |
1107 %! clf; | 1107 %! clf; |
1108 %! x = 0:0.1:10; | 1108 %! x = 0:0.1:10; |
1109 %! plot (x, sin(x), ";sin(x);"); | 1109 %! plot (x, sin(x), ';sin(x);'); |
1110 %! hold all; | 1110 %! hold all; |
1111 %! plot (x, cos(x), ";cos(x);"); | 1111 %! plot (x, cos(x), ';cos(x);'); |
1112 %! hold off; | 1112 %! hold off; |
1113 | 1113 |
1114 %!demo | 1114 %!demo |
1115 %! clf; | 1115 %! clf; |
1116 %! x = 0:0.1:10; | 1116 %! x = 0:0.1:10; |
1117 %! plot (x, sin(x), ";sin(x);"); | 1117 %! plot (x, sin(x), ';sin(x);'); |
1118 %! hold all; | 1118 %! hold all; |
1119 %! plot (x, cos(x), ";cos(x);"); | 1119 %! plot (x, cos(x), ';cos(x);'); |
1120 %! hold off; | 1120 %! hold off; |
1121 %! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside"); | 1121 %! legend ({'sin(x)', 'cos(x)'}, 'location', 'northeastoutside'); |
1122 | 1122 |
1123 %!demo | 1123 %!demo |
1124 %! clf; | 1124 %! clf; |
1125 %! x = 0:10; | 1125 %! x = 0:10; |
1126 %! plot (x, rand (11)); | 1126 %! plot (x, rand (11)); |
1127 %! xlabel ("Indices"); | 1127 %! xlabel ('Indices'); |
1128 %! ylabel ("Random Values"); | 1128 %! ylabel ('Random Values'); |
1129 %! title ('Legend "off" should delete the legend'); | 1129 %! title ('Legend ''off'' should delete the legend'); |
1130 %! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside"); | 1130 %! legend (cellstr (num2str ((1:10)')), 'location', 'northeastoutside'); |
1131 %! legend off; | 1131 %! legend off; |
1132 %! axis ([0, 10, 0 1]); | 1132 %! axis ([0, 10, 0 1]); |
1133 | 1133 |
1134 %!demo | 1134 %!demo |
1135 %! clf; | 1135 %! clf; |
1136 %! x = (1:5)'; | 1136 %! x = (1:5)'; |
1137 %! subplot (2, 2, 1); | 1137 %! subplot (2, 2, 1); |
1138 %! plot (x, rand (numel (x))); | 1138 %! plot (x, rand (numel (x))); |
1139 %! legend (cellstr (num2str (x)), "location", "northwestoutside"); | 1139 %! legend (cellstr (num2str (x)), 'location', 'northwestoutside'); |
1140 %! legend boxon; | 1140 %! legend boxon; |
1141 %! subplot (2, 2, 2); | 1141 %! subplot (2, 2, 2); |
1142 %! plot (x, rand (numel (x))); | 1142 %! plot (x, rand (numel (x))); |
1143 %! legend (cellstr (num2str (x)), "location", "northeastoutside"); | 1143 %! legend (cellstr (num2str (x)), 'location', 'northeastoutside'); |
1144 %! legend boxon; | 1144 %! legend boxon; |
1145 %! subplot (2, 2, 3); | 1145 %! subplot (2, 2, 3); |
1146 %! plot (x, rand (numel (x))); | 1146 %! plot (x, rand (numel (x))); |
1147 %! legend (cellstr (num2str (x)), "location", "southwestoutside"); | 1147 %! legend (cellstr (num2str (x)), 'location', 'southwestoutside'); |
1148 %! legend boxon; | 1148 %! legend boxon; |
1149 %! subplot (2, 2, 4); | 1149 %! subplot (2, 2, 4); |
1150 %! plot (x, rand (numel (x))); | 1150 %! plot (x, rand (numel (x))); |
1151 %! legend (cellstr (num2str (x)), "location", "southeastoutside"); | 1151 %! legend (cellstr (num2str (x)), 'location', 'southeastoutside'); |
1152 %! legend boxon; | 1152 %! legend boxon; |
1153 | 1153 |
1154 %!demo | 1154 %!demo |
1155 %! clf; | 1155 %! clf; |
1156 %! plot (rand (2)); | 1156 %! plot (rand (2)); |
1157 %! title ("Warn of extra labels"); | 1157 %! title ('Warn of extra labels'); |
1158 %! legend ("Hello", "World", "interpreter", "foobar"); | 1158 %! legend ('Hello', 'World', 'interpreter', 'foobar'); |
1159 | 1159 |
1160 %!demo | 1160 %!demo |
1161 %! clf; | 1161 %! clf; |
1162 %! plot (rand (2)); | 1162 %! plot (rand (2)); |
1163 %! title ("Turn off TeX interpreter"); | 1163 %! title ('Turn off TeX interpreter'); |
1164 %! h = legend ("Hello_World", "foo^bar"); | 1164 %! h = legend ('Hello_World', 'foo^bar'); |
1165 %! set (h, "interpreter", "none"); | 1165 %! set (h, 'interpreter', 'none'); |
1166 | 1166 |
1167 %!demo | 1167 %!demo |
1168 %! x = 0:10; | 1168 %! x = 0:10; |
1169 %! y1 = rand (size (x)); | 1169 %! y1 = rand (size (x)); |
1170 %! y2 = rand (size (x)); | 1170 %! y2 = rand (size (x)); |
1171 %! [ax, h1, h2] = plotyy (x, y1, x, y2); | 1171 %! [ax, h1, h2] = plotyy (x, y1, x, y2); |
1172 %! legend ([h1, h2], {"Blue", "Green"}, "location", "south"); | 1172 %! legend ([h1, h2], {'Blue', 'Green'}, 'location', 'south'); |
1173 | 1173 |
1174 %!demo | 1174 %!demo |
1175 %! x = 0:10; | 1175 %! x = 0:10; |
1176 %! y1 = rand (size (x)); | 1176 %! y1 = rand (size (x)); |
1177 %! y2 = rand (size (x)); | 1177 %! y2 = rand (size (x)); |
1178 %! [ax, h1, h2] = plotyy (x, y1, x, y2); | 1178 %! [ax, h1, h2] = plotyy (x, y1, x, y2); |
1179 %! legend ({"Blue", "Green"}, "location", "south"); | 1179 %! legend ({'Blue', 'Green'}, 'location', 'south'); |
1180 | 1180 |
1181 %!demo | 1181 %!demo |
1182 %! x = 0:10; | 1182 %! x = 0:10; |
1183 %! y1 = rand (size (x)); | 1183 %! y1 = rand (size (x)); |
1184 %! y2 = rand (size (x)); | 1184 %! y2 = rand (size (x)); |
1185 %! [ax, h1, h2] = plotyy (x, y1, x, y2); | 1185 %! [ax, h1, h2] = plotyy (x, y1, x, y2); |
1186 %! legend ("Blue", "Green", "location", "south"); | 1186 %! legend ('Blue', 'Green', 'location', 'south'); |
1187 | 1187 |