comparison scripts/plot/scatter.m @ 14011:431c6b00653d

scatter.m: Bug fix (34936). * __scatter__.m: Fix bug 34936. Don't ask gnuplot to render polygons with vertex color data. * scatter.m: Add / modify demos.
author Ben Abbott <bpabbott@mac.com>
date Wed, 07 Dec 2011 19:58:51 -0500
parents 5f0bb45e615c
children 72c96de7a403
comparison
equal deleted inserted replaced
14010:99e33d556d5c 14011:431c6b00653d
42 ## The marker to use can be changed with the @var{style} argument, that is a 42 ## The marker to use can be changed with the @var{style} argument, that is a
43 ## string defining a marker in the same manner as the @code{plot} command. 43 ## string defining a marker in the same manner as the @code{plot} command.
44 ## If the argument @code{"filled"} is given then the markers as filled. All 44 ## If the argument @code{"filled"} is given then the markers as filled. All
45 ## additional arguments are passed to the underlying patch command. 45 ## additional arguments are passed to the underlying patch command.
46 ## 46 ##
47 ## The optional return value @var{h} is a graphics handle to the hggroup 47 ## The optional return value @var{h} provides a handle to the patch object
48 ## object representing the points.
49 ## 48 ##
50 ## @example 49 ## @example
51 ## @group 50 ## @group
52 ## x = randn (100, 1); 51 ## x = randn (100, 1);
53 ## y = randn (100, 1); 52 ## y = randn (100, 1);
81 80
82 endfunction 81 endfunction
83 82
84 83
85 %!demo 84 %!demo
85 %! clf
86 %! x = randn (100, 1); 86 %! x = randn (100, 1);
87 %! y = randn (100, 1); 87 %! y = randn (100, 1);
88 %! scatter (x, y, "r"); 88 %! scatter (x, y, "r");
89 89
90 %!demo 90 %!demo
91 %! clf
91 %! x = randn (100, 1); 92 %! x = randn (100, 1);
92 %! y = randn (100, 1); 93 %! y = randn (100, 1);
93 %! scatter (x, y, [], sqrt (x.^2 + y.^2)); 94 %! scatter (x, y, [], sqrt (x.^2 + y.^2));
94 95
95 %!demo 96 %!demo
97 %! clf
96 %! rand_10x1_data1 = [0.171577, 0.404796, 0.025469, 0.335309, 0.047814, 0.898480, 0.639599, 0.700247, 0.497798, 0.737940]; 98 %! rand_10x1_data1 = [0.171577, 0.404796, 0.025469, 0.335309, 0.047814, 0.898480, 0.639599, 0.700247, 0.497798, 0.737940];
97 %! rand_10x1_data2 = [0.75495, 0.83991, 0.80850, 0.73603, 0.19360, 0.72573, 0.69371, 0.74388, 0.13837, 0.54143]; 99 %! rand_10x1_data2 = [0.75495, 0.83991, 0.80850, 0.73603, 0.19360, 0.72573, 0.69371, 0.74388, 0.13837, 0.54143];
98 %! x = rand_10x1_data1; 100 %! x = rand_10x1_data1;
99 %! y = rand_10x1_data2; 101 %! y = rand_10x1_data2;
100 %! s = 10 - 10*log (x.^2 + y.^2); 102 %! s = 10 - 10*log (x.^2 + y.^2);
101 %! h = scatter (x, y, s, s, "s", "filled"); 103 %! h = scatter (x, y, s, s, "s", "filled");
102 104
103 %!demo 105 %!demo
106 %! clf
104 %! rand_10x1_data3 = [0.42262, 0.51623, 0.65992, 0.14999, 0.68385, 0.55929, 0.52251, 0.92204, 0.19762, 0.93726]; 107 %! rand_10x1_data3 = [0.42262, 0.51623, 0.65992, 0.14999, 0.68385, 0.55929, 0.52251, 0.92204, 0.19762, 0.93726];
105 %! rand_10x1_data4 = [0.020207, 0.527193, 0.443472, 0.061683, 0.370277, 0.947349, 0.249591, 0.666304, 0.134247, 0.920356]; 108 %! rand_10x1_data4 = [0.020207, 0.527193, 0.443472, 0.061683, 0.370277, 0.947349, 0.249591, 0.666304, 0.134247, 0.920356];
106 %! x = rand_10x1_data3; 109 %! x = rand_10x1_data3;
107 %! y = rand_10x1_data4; 110 %! y = rand_10x1_data4;
108 %! s = 10 - 10*log (x.^2 + y.^2); 111 %! s = 10 - 10*log (x.^2 + y.^2);
109 %! h = scatter (x, y, [], "r", "s", "filled"); 112 %! h = scatter (x, y, [], "r", "s", "filled");
110 113
111 %!demo 114 %!demo
115 %! clf
112 %! rand_10x1_data5 = [0.777753, 0.093848, 0.183162, 0.399499, 0.337997, 0.686724, 0.073906, 0.651808, 0.869273, 0.137949]; 116 %! rand_10x1_data5 = [0.777753, 0.093848, 0.183162, 0.399499, 0.337997, 0.686724, 0.073906, 0.651808, 0.869273, 0.137949];
113 %! rand_10x1_data6 = [0.37460, 0.25027, 0.19510, 0.51182, 0.54704, 0.56087, 0.24853, 0.75443, 0.42712, 0.44273]; 117 %! rand_10x1_data6 = [0.37460, 0.25027, 0.19510, 0.51182, 0.54704, 0.56087, 0.24853, 0.75443, 0.42712, 0.44273];
114 %! x = rand_10x1_data5; 118 %! x = rand_10x1_data5;
115 %! y = rand_10x1_data6; 119 %! y = rand_10x1_data6;
116 %! s = 10 - 10*log (x.^2 + y.^2); 120 %! s = 10 - 10*log (x.^2 + y.^2);
117 %! h = scatter (x, y, [], "r", "s"); 121 %! h = scatter (x, y, [], "r", "s");
118 122
119 %!demo 123 %!demo
120 %! n = 500; 124 %! k = 1;
121 %! x = rand (n,1); 125 %! clf
122 %! y = rand (n,1); 126 %! for m = [1, 3]
123 %! idx = ceil (rand (n,1)*3); 127 %! for n = [101, 50, 1]
124 %! colors = eye(3)(idx, :); 128 %! x = rand (n, 1);
125 %! scatter (x,y,15, colors, "filled"); 129 %! y = rand (n, 1);
130 %! if (m > 1)
131 %! str = "Three Colors";
132 %! idx = ceil (rand (n, 1) * 3);
133 %! colors = eye(3);
134 %! colors = colors(idx, :);
135 %! else
136 %! str = "Random Colors";
137 %! colors = rand (n, m);
138 %! endif
139 %! if (n == 1)
140 %! str = sprintf ("%s: 1 point", str);
141 %! elseif (n < 100)
142 %! str = sprintf ("%s: < 100 points", str);
143 %! else
144 %! str = sprintf ("%s: > 100 points", str);
145 %! endif
146 %! subplot (2, 3, k)
147 %! k = k + 1;
148 %! scatter (x, y, 15, colors, "filled")
149 %! axis ([0 1 0 1])
150 %! title (str)
151 %! endfor
152 %! endfor
126 153
154 %!demo
155 %! k = 1;
156 %! clf
157 %! for m = [1, 3]
158 %! for n = [101, 50, 1]
159 %! x = rand (n, 1);
160 %! y = rand (n, 1);
161 %! if (m > 1)
162 %! str = "Three Colors";
163 %! idx = ceil (rand (n, 1) * 3);
164 %! colors = eye(3);
165 %! colors = colors(idx, :);
166 %! else
167 %! str = "Random Colors";
168 %! colors = rand (n, m);
169 %! endif
170 %! if (n == 1)
171 %! str = sprintf ("%s: 1 point", str);
172 %! elseif (n < 100)
173 %! str = sprintf ("%s: < 100 points", str);
174 %! else
175 %! str = sprintf ("%s: > 100 points", str);
176 %! endif
177 %! subplot (2, 3, k)
178 %! k = k + 1;
179 %! scatter (x, y, 15, colors)
180 %! axis ([0 1 0 1])
181 %! title (str)
182 %! endfor
183 %! endfor