summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorSamuel GOUGEON <sgougeon@free.fr>2020-02-20 19:44:57 +0100
committerClément David <clement.david@esi-group.com>2021-04-08 16:47:46 +0200
commit01100bb8542b0790fb1cd64212514f5632937e55 (patch)
treef9d60f226278f237cb7b042e06cc3191252f8967 /scilab/modules
parentf0635bd2c4c07f4628d7a59796c1b4d4126f9b51 (diff)
downloadscilab-01100bb8542b0790fb1cd64212514f5632937e55.zip
scilab-01100bb8542b0790fb1cd64212514f5632937e55.tar.gz
* Bug 15481 fixed: scatter() & scatter3d()
http://bugzilla.scilab.org/15481 Moved from master @ https://codereview.scilab.org/21373 A short list of fixed issues: USAGES * scatter() nor scatter3d() could display a single data point (reported bug). * The type of X, Y, Z was not checked, leading to weird error messages. * X, Y (and Z) should have had the same shape, while only the same length is actually required. * The properties names were case-sensitive. * Colors could not be scaled to data < %eps. * Colors could not be specified by their #RRGGBB code nor their index. * The handle of polylines was returned even when not requested. * The example cleared the current figure instead of the current axes. INTERNAL a) Warnings were generated, instead of errors. b) Warnings messages were not standard. c) Warning messages were not localized. d) The same colorIndex name was used to name a function and a regular variable. DOCUMENTATION * The thickness option is for all markers. It was not indicated. * Examples: scatter(): . 2 clouds of points : images did not match the code (negative coord impossible from rand()) . First spiral: the image did not match with the example code: The code does not vary the size of dots. scatter3d(): last example: . p refered to nothing. . color() was called with RGB in [0,1] instead of in [0,255] => dark * UNIT TESTS: More than 50+50 tests added. * FEATURES ADDED: + colors identified with "#RRGGBB" or indices + options "smallOnTop" and "datatips" (documented only for scatter()) Change-Id: Id26797f8e713d7e3078031c8fc4d1db7c529606c
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/graphics/help/en_US/2d_plot/scatter.xml594
-rw-r--r--scilab/modules/graphics/help/en_US/3d_plot/scatter3d.xml660
-rw-r--r--scilab/modules/graphics/macros/scatter.sci59
-rw-r--r--scilab/modules/graphics/macros/scatter3d.sci795
-rw-r--r--scilab/modules/graphics/tests/nonreg_tests/bug_15481.tst26
-rw-r--r--scilab/modules/graphics/tests/unit_tests/scatter.dia.ref222
-rw-r--r--scilab/modules/graphics/tests/unit_tests/scatter.tst146
-rw-r--r--scilab/modules/graphics/tests/unit_tests/scatter3d.tst131
-rw-r--r--scilab/modules/helptools/etc/images_md5.txt18
-rw-r--r--scilab/modules/helptools/images/scatter3d_1.pngbin40263 -> 60375 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_2.pngbin39183 -> 56944 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_3.pngbin45296 -> 52025 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_4.pngbin43307 -> 48401 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_5.pngbin38035 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_6.pngbin48066 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_7.pngbin70876 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_8.pngbin39183 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter3d_9.pngbin41225 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_1.pngbin14717 -> 73482 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_2.pngbin12110 -> 36714 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_3.pngbin18049 -> 24354 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_4.pngbin18612 -> 36616 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_5.pngbin10000 -> 26814 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_6.pngbin20072 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_7.pngbin12887 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_8.pngbin10073 -> 0 bytes
-rw-r--r--scilab/modules/helptools/images/scatter_9.pngbin20405 -> 0 bytes
27 files changed, 1387 insertions, 1264 deletions
diff --git a/scilab/modules/graphics/help/en_US/2d_plot/scatter.xml b/scilab/modules/graphics/help/en_US/2d_plot/scatter.xml
index f916f15..68f30bf 100644
--- a/scilab/modules/graphics/help/en_US/2d_plot/scatter.xml
+++ b/scilab/modules/graphics/help/en_US/2d_plot/scatter.xml
@@ -2,8 +2,8 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch 4 * Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -24,8 +24,16 @@
24 <refsynopsisdiv> 24 <refsynopsisdiv>
25 <title>Syntax</title> 25 <title>Syntax</title>
26 <synopsis> 26 <synopsis>
27 polyline = scatter(x, y, msizes, mcolors, "fill", marker, &lt;marker_property, value&gt;) 27 scatter() // Example
28 polyline = scatter(axes_handle,...) 28 scatter(x, y)
29 scatter(x, y, msizes)
30 scatter(x, y, msizes, mcolors)
31 scatter(.., "fill")
32 scatter(.., "smallOnTop")
33 scatter(.., marker)
34 scatter(..., &lt;marker_property, value>)
35 scatter(axes, ..)
36 polyline = scatter(..)
29 </synopsis> 37 </synopsis>
30 </refsynopsisdiv> 38 </refsynopsisdiv>
31 <refsection> 39 <refsection>
@@ -41,17 +49,28 @@
41 </listitem> 49 </listitem>
42 </varlistentry> 50 </varlistentry>
43 <varlistentry> 51 <varlistentry>
52 <term>axes</term>
53 <listitem>
54 Handle of the graphical axes in which the scatter plot must be drawn.
55 By default, the current axes is targeted.
56 <para/>
57 </listitem>
58 </varlistentry>
59 <varlistentry>
60 <term>polyline</term>
61 <listitem>
62 Handle of the created polyline.
63 <para/>
64 </listitem>
65 </varlistentry>
66 <varlistentry>
44 <term>msizes</term> 67 <term>msizes</term>
45 <listitem> 68 <listitem>
46 <para> 69 <para>
47 Specifying the sizes of the markers. To plot each marker with equal sizes, 70 Sizes of the markers, as of the area of the circle surrounding the marker,
48 specify <varname>msizes</varname> as a scalar. 71 in point-square. Default value = 36. If it is scalar,
49 To plot each marker with a different size, specify <varname>msizes</varname> 72 the same size is used for all markers. Otherwise <varname>msizes</varname>
50 as a vector with length equal to the length of <varname>x</varname> and 73 and <varname>x</varname> must have the same number of elements.
51 <varname>x</varname>.
52 The units for <varname>msizes</varname> is points squared with a default
53 value of 36 points squared.
54 The size equals the area of the circle surrounding the marker.
55 </para> 74 </para>
56 </listitem> 75 </listitem>
57 </varlistentry> 76 </varlistentry>
@@ -59,18 +78,35 @@
59 <term>mcolors</term> 78 <term>mcolors</term>
60 <listitem> 79 <listitem>
61 <para> 80 <para>
62 Specifying the colors of the markers. 81 Colors of markers. If it is scalar, the same color is used for all markers.
63 To plot each marker with the same color, specify <varname>mcolors</varname> 82 Otherwise, <varname>mcolors</varname> and <varname>x</varname> must have
64 as a string representing a known color, see <link linkend="color_list">color_list</link>. 83 the same number of elements.
65 A color can also be specified by a vector of 3 RGB values between 0 and 1. 84 </para>
66 To plot each marker with a different color, specify <varname>mcolors</varname> 85 <para>
67 as a vector with length equal to the length of <varname>x</varname>. 86 The same color is used for filling the body and drawing the edge of markers.
87 </para>
88 <para>
68 The values of <varname>mcolors</varname> are linearly mapped to the colors 89 The values of <varname>mcolors</varname> are linearly mapped to the colors
69 in the current colormap. 90 in the current colormap.
70 Colors can also by specified by a matrix of RGB values or a vector of 91 </para>
71 strings representing known colors. 92 <para>
72 A matrix of RGB values has 3 columns and the number of rows equals the 93 A color can be specified by one of the following:
73 length of <varname>x</varname>. 94 <itemizedlist>
95 <listitem>
96 Its name, among the predefined names colors
97 (see the <link linkend="color_list">color_list</link>).
98 </listitem>
99 <listitem>
100 Its standard hexadecimal RGB code as a string, like "#A532FB".
101 </listitem>
102 <listitem>
103 A matrix of RGB values with 3 columns and n rows, with Red Green and
104 Blue intensities in [0,1].
105 </listitem>
106 <listitem>
107 Its index in the current color map
108 </listitem>
109 </itemizedlist>
74 The default color is "blue". 110 The default color is "blue".
75 </para> 111 </para>
76 </listitem> 112 </listitem>
@@ -79,11 +115,21 @@
79 <term>"fill"</term> 115 <term>"fill"</term>
80 <listitem> 116 <listitem>
81 <para> 117 <para>
82 This string indicates that the markers are filled with some colors. 118 By default, only the edge of markers is drawn, unless this keyword or the
83 By default, the filling colors are the same as the patterns ones.
84 Both sets of colors can be defined independently by using the properties
85 <varname>"markerFaceColor"</varname> or 119 <varname>"markerFaceColor"</varname> or
86 <varname>"markerBackgroundColor"</varname>. 120 <varname>"markerBackgroundColor"</varname> properties are set.
121 </para>
122 </listitem>
123 </varlistentry>
124 <varlistentry>
125 <term>"smallOnTop"</term>
126 <listitem>
127 <para>
128 When markers have not all the same size and the population of points becomes
129 crowdy, big markers can hide smaller ones located around the same place.
130 This option can be used to avoid such masking effects. Then points are
131 priorly sorted by decreasing sizes, in order to plot the smallest points
132 at the end, on top of bigger ones.
87 </para> 133 </para>
88 </listitem> 134 </listitem>
89 </varlistentry> 135 </varlistentry>
@@ -91,8 +137,8 @@
91 <term>marker</term> 137 <term>marker</term>
92 <listitem> 138 <listitem>
93 <para> 139 <para>
94 Select the type of the marker. The same marker shape is used for all 140 Selects the shape of the markers. The same shape is used for all
95 specified points. The figure below shows the 15 different marker types. 141 specified points. The figure below shows the 15 different marker shapes.
96 </para> 142 </para>
97 <para> 143 <para>
98 <inlinemediaobject> 144 <inlinemediaobject>
@@ -102,181 +148,154 @@
102 </inlinemediaobject> 148 </inlinemediaobject>
103 </para> 149 </para>
104 <para> 150 <para>
105 Marker types are specified by strings, see the table below. 151 Each marker shape is specified either by its index (list above) or by
152 its string symbol (table below).
106 </para> 153 </para>
107 <para> 154 <para>
108 <informaltable border="1"> 155 <informaltable border="1">
109 <tr> 156 <tr><td>Index</td>
110 <td> 157 <td>String</td>
111 String 158 <td>Marker type</td>
112 </td>
113 <td>
114 Marker type
115 </td>
116 </tr> 159 </tr>
117 <tr> 160 <tr>
118 <td> 161 <td>0</td>
119 <literal>"."</literal> 162 <td><literal>"."</literal></td>
120 </td>
121 <td>Point</td> 163 <td>Point</td>
122 </tr> 164 </tr>
123 <tr> 165 <tr>
124 <td> 166 <td>1</td>
125 <literal>"+"</literal> 167 <td><literal>"+"</literal></td>
126 </td>
127 <td>Plus sign</td> 168 <td>Plus sign</td>
128 </tr> 169 </tr>
129 <tr> 170 <tr>
130 <td> 171 <td>2</td>
131 <literal>"x"</literal> 172 <td><literal>"x"</literal></td>
132 </td>
133 <td>Cross</td> 173 <td>Cross</td>
134 </tr> 174 </tr>
135 <tr> 175 <tr>
136 <td> 176 <td>3</td>
137 <literal>"circle plus"</literal> 177 <td><literal>"circle plus"</literal></td>
138 </td>
139 <td>Circle with plus</td> 178 <td>Circle with plus</td>
140 </tr> 179 </tr>
141 <tr> 180 <tr>
142 <td> 181 <td>4</td>
143 <literal>"filled diamond"</literal> 182 <td><literal>"filled diamond"</literal></td>
144 </td>
145 <td>Filled diamond</td> 183 <td>Filled diamond</td>
146 </tr> 184 </tr>
147 <tr> 185 <tr>
148 <td> 186 <td>5</td>
149 <literal>"d"</literal> or 187 <td><literal>"d"</literal> or <literal>"diamond"</literal></td>
150 <literal>"diamond"</literal>
151 </td>
152 <td>Diamond</td> 188 <td>Diamond</td>
153 </tr> 189 </tr>
154 <tr> 190 <tr>
155 <td> 191 <td>6</td>
156 <literal>"^"</literal> 192 <td><literal>"^"</literal></td>
157 </td>
158 <td>Upward-pointing triangle</td> 193 <td>Upward-pointing triangle</td>
159 </tr> 194 </tr>
160 <tr> 195 <tr>
161 <td> 196 <td>7</td>
162 <literal>"v"</literal> 197 <td><literal>"v"</literal></td>
163 </td>
164 <td>Downward-pointing triangle</td> 198 <td>Downward-pointing triangle</td>
165 </tr> 199 </tr>
166 <tr> 200 <tr>
167 <td> 201 <td>8</td>
168 <literal>"diamond plus"</literal> 202 <td><literal>"diamond plus"</literal></td>
169 </td>
170 <td>Diamond with plus</td> 203 <td>Diamond with plus</td>
171 </tr> 204 </tr>
172 <tr> 205 <tr>
173 <td> 206 <td>9</td>
174 <literal>"o"</literal> 207 <td><literal>"o"</literal></td>
175 </td>
176 <td>Circle (default)</td> 208 <td>Circle (default)</td>
177 </tr> 209 </tr>
178 <tr> 210 <tr>
179 <td> 211 <td>10</td>
180 <literal>"*"</literal> 212 <td><literal>"*"</literal></td>
181 </td>
182 <td>Asterisk</td> 213 <td>Asterisk</td>
183 </tr> 214 </tr>
184 <tr> 215 <tr>
185 <td> 216 <td>11</td>
186 <literal>"s"</literal> or 217 <td><literal>"s"</literal> or <literal>"square"</literal></td>
187 <literal>"square"</literal>
188 </td>
189 <td>Square</td> 218 <td>Square</td>
190 </tr> 219 </tr>
191 <tr> 220 <tr>
192 <td> 221 <td>12</td>
193 <literal>"&gt;"</literal> 222 <td><literal>">"</literal></td>
194 </td>
195 <td>Right-pointing triangle</td> 223 <td>Right-pointing triangle</td>
196 </tr> 224 </tr>
197 <tr> 225 <tr>
198 <td> 226 <td>13</td>
199 <literal>"&lt;"</literal> 227 <td><literal>"&lt;"</literal></td>
200 </td>
201 <td>Left-pointing triangle</td> 228 <td>Left-pointing triangle</td>
202 </tr> 229 </tr>
203 <tr> 230 <tr>
204 <td> 231 <td>14</td>
205 <literal>"pentagram"</literal> or 232 <td><literal>"pentagram"</literal> or <literal>"p"</literal></td>
206 <literal>"p"</literal>
207 </td>
208 <td>Five-pointed star</td> 233 <td>Five-pointed star</td>
209 </tr> 234 </tr>
210 </informaltable> 235 </informaltable>
211 </para> 236 </para>
212 </listitem> 237 </listitem>
213 </varlistentry> 238 </varlistentry>
239 </variablelist>
240 <refsect3>
241 <title>Property Name, Value pairs</title>
242 <para>
243 A series of property &lt;Name,Value> pairs can be used to specify
244 the filling color of markers body, the color and thickness of the markers edges,
245 or the points on which a datatip must be created.
246 </para>
247 </refsect3>
248 <variablelist>
214 <varlistentry> 249 <varlistentry>
215 <term>&lt;marker_property, value&gt;</term> 250 <term>"marker",value or "markerStyle",value</term>
216 <listitem>
217 <para>
218 A sequence of property value pairs can be used to specify type, color and
219 line width of the markers.
220 </para>
221 </listitem>
222 </varlistentry>
223 <varlistentry>
224 <term>&lt;"marker", value&gt; or &lt;"markerStyle", value&gt;</term>
225 <listitem> 251 <listitem>
226 <para> 252 <para>
227 Specify the type of the marker, see the table above. 253 Shape of the marker (index or string keyword). See the table above.
228 </para> 254 </para>
229 </listitem> 255 </listitem>
230 </varlistentry> 256 </varlistentry>
231 <varlistentry> 257 <varlistentry>
232 <term>&lt;"markerEdgeColor", value&gt; or &lt;"markerForeground", value&gt;</term> 258 <term>"markerEdgeColor",value or "markerForeground",value</term>
233 <listitem> 259 <listitem>
234 <para> 260 <para>
235 Specify the foreground color of the marker. 261 Color of the edge of markers. Colors can be specified as for
236 A color can be specified by a string representing a known color, 262 <varname>mcolors</varname>.
237 see <link linkend="color_list">color_list</link>. 263 This option supersedes <varname>mcolors</varname>.
238 A color can also be specified by a vector of 3 RGB values.
239 RGB values correspond to red, green and blue intensity between 0 and 1.
240 This option is superseded by argument <varname>mcolors</varname>.
241 </para> 264 </para>
242 </listitem> 265 </listitem>
243 </varlistentry> 266 </varlistentry>
244 <varlistentry> 267 <varlistentry>
245 <term>&lt;"markerFaceColor",value&gt; or &lt;"markerBackground",value&gt;</term> 268 <term>"markerFaceColor",value or "markerBackground",value</term>
246 <listitem> 269 <listitem>
247 <para> 270 <para>
248 Specify the background color of the marker. 271 Color filling the body of markers. Colors can be specified as for
249 A color can be specified by a string representing a known color 272 <varname>mcolors</varname>.
250 see <link linkend="color_list">color_list</link>. 273 This option supersedes <varname>mcolors</varname>.
251 A color can also be specified by a vector of 3 RGB values.
252 RGB values correspond to red, green and blue intensity between 0 and 1.
253 This option is superseded by argument <varname>mcolors</varname>.
254 </para> 274 </para>
255 </listitem> 275 </listitem>
256 </varlistentry> 276 </varlistentry>
257 <varlistentry> 277 <varlistentry>
258 <term>&lt;"linewidth",value&gt; or &lt;"thickness",value&gt;</term> 278 <term>"linewidth",value or "thickness",value</term>
259 <listitem> 279 <listitem>
260 <para> 280 <para>
261 Specify the thickness of the edge of the marker. 281 Specify the thickness of the edge for all markers.
262 The unit for the value is one point. 282 The unit for the value is one point.
263 </para> 283 </para>
264 </listitem> 284 </listitem>
265 </varlistentry> 285 </varlistentry>
266 <varlistentry> 286 <varlistentry>
267 <term>&lt;axes_handle&gt;</term> 287 <term>"datatips", k</term>
268 <listitem> 288 <listitem>
269 <para>This optional argument forces the scatter plot to appear inside the 289 <para>
270 selected axes given by <literal>axes_handle</literal> rather than inside the 290 Creates a datatip for all (X,Y) points whose indices are in the vector
271 current axes, see <link linkend="gca">gca</link>. 291 <varname>k</varname>.
272 </para> 292 </para>
273 </listitem>
274 </varlistentry>
275 <varlistentry>
276 <term>polyline</term>
277 <listitem>
278 <para> 293 <para>
279 Handle of the created polyline. 294 The <literal>datatip_display_mode</literal> is set to
295 <literal>"mouseover"</literal>. The datatip anchor is reduced to a point
296 set at the middle of the marker. The default datatips display the
297 (x,y) coordinates of the point. If <varname>msizes</varname> is a vector,
298 the size of each marker is also displayed.
280 </para> 299 </para>
281 </listitem> 300 </listitem>
282 </varlistentry> 301 </varlistentry>
@@ -298,181 +317,229 @@
298 For more details see the description of the arguments and the examples. 317 For more details see the description of the arguments and the examples.
299 </para> 318 </para>
300 <note> 319 <note>
301 To skip an argument, just replace it with <literal>[]</literal> like in 320 To skip an argument, just .. skip it, or replace it with <literal>[]</literal>, like in
302 <literal>scatter3d(x,y,z,[],mcolors)</literal>. 321 <literal>scatter3d(x,y, , mcolors)</literal> or <literal>scatter3d(x,y,[], mcolors)</literal>.
303 </note> 322 </note>
304 </refsection> 323 </refsection>
305 <refsection> 324 <refsection>
306 <title>Examples</title> 325 <title>Examples</title>
307 <para> 326 <para>
308 Create 2D scatter plot 327 With the default circle shape, and the same color for all points:
309 </para> 328 </para>
310 <programlisting role="example"><![CDATA[ 329 <programlisting role="example"><![CDATA[
311// x and y initialisation 330n = 130;
312x = linspace(0,2,200); 331x = rand(1,n);
313y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)); 332y = rand(1,n);
314// create 2D scatter plot 333
315scatter(x,y); 334clf
335subplot(2,3,1)
336scatter(x, y)
337title("scatter(x, y)", "fontsize",3)
338
339subplot(2,3,2)
340scatter(x, y, 100)
341title("scatter(x, y, 100)", "fontsize",3)
342
343subplot(2,3,3)
344mAreas = 10.^grand(1,n,"unf",1,2.4);
345scatter(x, y, mAreas)
346title("scatter(x, y, mAreas)", "fontsize",3)
347
348subplot(2,3,4)
349scatter(x, y, , "orange")
350tit = "scatter(x, y, ,""orange"")";
351title(tit, "fontsize",3)
352
353subplot(2,3,5)
354scatter(x, y, "fill")
355tit = "scatter(x, y, ""fill"")";
356title(tit, "fontsize",3)
357
358subplot(2,3,6)
359scatter(x, y, mAreas, "markerBackground", "yellow")
360tit = "scatter(x, y, mAreas,""markerBackground"", ""yellow"")";
361title(tit, "fontsize",1)
316 ]]></programlisting> 362 ]]></programlisting>
317 <scilab:image> 363 <scilab:image>
318 x = linspace(0,2,200) 364 n = 130;
319 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)) 365 x = rand(1,n);
320 scatter(x,y) 366 y = rand(1,n);
367
368 clf
369 subplot(2,3,1)
370 scatter(x, y)
371 title("scatter(x, y)", "fontsize",3)
372
373 subplot(2,3,2)
374 scatter(x, y, 100)
375 title("scatter(x, y, 100)", "fontsize",3)
376
377 subplot(2,3,3)
378 mAreas = 10.^grand(1,n,"unf",1,2.4);
379 scatter(x, y, mAreas)
380 title("scatter(x, y, mAreas)", "fontsize",3)
381
382 subplot(2,3,4)
383 scatter(x, y, , "orange")
384 tit = "scatter(x, y, ,""orange"")";
385 title(tit, "fontsize",3)
386
387 subplot(2,3,5)
388 scatter(x, y, "fill")
389 tit = "scatter(x, y, ""fill"")";
390 title(tit, "fontsize",3)
391
392 subplot(2,3,6)
393 scatter(x, y, mAreas, "markerBackground", "yellow")
394 tit = "scatter(x, y, mAreas,""markerBackground"", ""yellow"")";
395 title(tit, "fontsize",1)
396
397 gcf().axes_size = [750 500];
321 </scilab:image> 398 </scilab:image>
322 <para> 399 <para>
323 Vary marker size 400 <emphasis role="bold">Option "smallOnTop"</emphasis>, avoiding intermasking effects:
324 </para> 401 </para>
325 <programlisting role="example"><![CDATA[ 402 <programlisting role="example"><![CDATA[
326// x and y initialisation 403n = 170;
327x = linspace(0,2,200); 404x = rand(1,n);
328y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)); 405y = rand(1,n);
329// specify different sizes 406mAreas = 10.^grand(1,n,"unf",1,2.8);
330s = linspace(1,30,length(x)); 407
331// create 2D scatter plot 408clf
332scatter(x, y, s); 409subplot(1,2,1)
410scatter(x, y, mAreas, "wheat", "fill", "markerEdgeColor", "red")
411title("Raw display", "fontsize",3)
412
413subplot(1,2,2)
414scatter(x, y, mAreas, "wheat", "fill", "smallOnTop", "markerEdgeColor", "red")
415title("""SmallOnTop"" option", "fontsize",3)
333 ]]></programlisting> 416 ]]></programlisting>
334 <scilab:image> 417 <scilab:image>
335 x = linspace(0,2,200) 418 n = 170;
336 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)) 419 x = rand(1,n);
337 s = linspace(1,30,length(x)) 420 y = rand(1,n);
338 scatter(x,y,s) 421 mAreas = 10.^grand(1,n,"unf",1,2.8);
422
423 clf
424 subplot(1,2,1)
425 scatter(x, y, mAreas, "wheat", "fill", "markerEdgeColor", "red")
426 title("Raw display", "fontsize",3)
427
428 subplot(1,2,2)
429 scatter(x, y, mAreas, "wheat", "fill", "SmallOnTop", "markerEdgeColor", "red")
430 title("""SmallOnTop"" option", "fontsize",3)
431
432 gcf().axes_size = [600 270];
339 </scilab:image> 433 </scilab:image>
434
340 <para> 435 <para>
341 Vary marker size and color 436 Vary marker size and color
342 </para> 437 </para>
343 <programlisting role="example"><![CDATA[ 438 <programlisting role="example"><![CDATA[
344// x and y initialisation
345x = linspace(0, 2, 200);
346y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
347// specify different sizes
348s = linspace(1, 30, length(x));
349// set color map
350gcf().color_map = coolcolormap(64);
351// colors according to x values
352c = x;
353// create 2D scatter plot
354scatter(x,y,s,c);
355 ]]></programlisting>
356 <scilab:image>
357 x = linspace(0,2,200)
358 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x))
359 s = linspace(1,30,length(x))
360 gcf().color_map = coolcolormap(64)
361 c = x
362 scatter(x,y,s,c)
363 </scilab:image>
364 <para>
365 Fill the markers
366 </para>
367 <programlisting role="example"><![CDATA[
368// x and y initialisation
369x = linspace(0, 2, 200); 439x = linspace(0, 2, 200);
370y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)); 440y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
371// specify different sizes 441
372s = linspace(1, 30, length(x)); 442s = linspace(1, 30, length(x)); // specify different sizes
373// set color map 443gcf().color_map = coolcolormap(64); // set color map
374gcf().color_map = coolcolormap(64); 444c = x; // colors according to x values
375// colors according to y values 445subplot(1,2,1)
376c = y; 446scatter(x, y, s, c); // create 2D scatter plot
377// create 2D scatter plot 447
448// Fill the markers
449subplot(1,2,2)
378scatter(x, y, s, c, "fill"); 450scatter(x, y, s, c, "fill");
379 ]]></programlisting> 451 ]]></programlisting>
380 <scilab:image> 452 <scilab:image>
381 x = linspace(0,2,200) 453 x = linspace(0, 2, 200);
382 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)) 454 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
383 s = linspace(1,30,length(x)) 455
384 gcf().color_map = coolcolormap(64); 456 s = linspace(1, 30, length(x)); // specify different sizes
385 c = y 457 gcf().color_map = coolcolormap(64); // set color map
386 scatter(x,y,s,c,"fill") 458 c = x; // colors according to x values
459 subplot(1,2,1)
460 scatter(x, y, s, c); // create 2D scatter plot
461
462 // Fill the markers
463 subplot(1,2,2)
464 scatter(x, y, s, c, "fill");
465 gcf().axes_size = [700 350];
387 </scilab:image> 466 </scilab:image>
388 <para> 467 <para>
389 Specify marker symbol 468 Specify the marker
390 </para> 469 </para>
391 <programlisting role="example"><![CDATA[ 470 <programlisting role="example"><![CDATA[
392// x and y initialisation
393x = rand(1, 200); 471x = rand(1, 200);
394y = rand(1, 200); 472y = rand(1, 200);
395// create 2D scatter plot 473
474subplot(2,2,1)
396scatter(x, y, "d"); 475scatter(x, y, "d");
397 ]]></programlisting> 476
398 <scilab:image> 477subplot(2,2,2)
399 x = rand(1,200)
400 y = rand(1,200)
401 scatter(x,y,"d")
402 </scilab:image>
403 <para>
404 Change marker color and line width
405 </para>
406 <programlisting role="example"><![CDATA[
407// x and y initialisation
408x = rand(1, 200);
409y = rand(1, 200);
410// create 2D scatter plot
411scatter(x, y, "markerEdgeColor",[0 .4 .4],... 478scatter(x, y, "markerEdgeColor",[0 .4 .4],...
412 "markerFaceColor",[0 .8 .8],... 479 "markerFaceColor","magenta",...
413 "linewidth",1.5); 480 "linewidth",1.5);
481
482subplot(2,2,3)
483scatter(x, y, 60, "red", "+"); // Marker's symbol
484
485subplot(2,2,4)
486scatter(x, y, 60, "green", 14); // Marker's index
414 ]]></programlisting> 487 ]]></programlisting>
415 <scilab:image> 488 <scilab:image>
416 x = rand(1,200) 489 x = rand(1, 200);
417 y = rand(1,200) 490 y = rand(1, 200);
418 scatter(x,y,"markerEdgeColor",[0 .4 .4],... 491
419 "markerFaceColor",[0 .8 .8],... 492 subplot(2,2,1)
420 "linewidth",1.5) 493 scatter(x, y, "d");
494
495 subplot(2,2,2)
496 scatter(x, y, "markerEdgeColor",[0 .4 .4],...
497 "markerFaceColor","magenta",...
498 "linewidth",1.5);
499
500 subplot(2,2,3)
501 scatter(x, y, 60, "red", "+"); // Marker's symbol
502
503 subplot(2,2,4)
504 scatter(x, y, 60, "green", 14); // Marker's index
505
506 gcf().axes_size = [600 500];
421 </scilab:image> 507 </scilab:image>
422 <para> 508 <para>
423 Specify subplot for scatter plot 509 Post-processing a scatter plot:
424 </para> 510 </para>
425 <programlisting role="example"><![CDATA[ 511 <programlisting role="example"><![CDATA[
426// x and y initialisation 512n = 150;
427x = linspace(0, 2, 100); 513x = rand(1,n);
428y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)); 514y = rand(1,n);
429// create 2D scatter subplot 515mAreas = 10.^grand(1,n,"unf",1,2.8);
430subplot(2, 1, 1) 516
431scatter(gca(), x, y); 517clf
432// create 2D scatter subplot 518p = scatter(x, y, mAreas, "yel", "fill", "markerEdgeColor", "red")
433subplot(2, 1, 2) 519
434scatter(gca(), x, y, "fill", "s"); 520// Post-processing
435 ]]></programlisting> 521k = mAreas<median(mAreas)*2;
436 <scilab:image> 522bg = ones(1,n) * p.mark_background;
437 x = linspace(0,2,100) 523bg(k) = color("orange");
438 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)) 524p.mark_background = bg;
439 subplot(2,1,1) 525 ]]></programlisting>
440 scatter(gca(),x,y) 526 <scilab:image><![CDATA[
441 subplot(2,1,2) 527 n = 150;
442 scatter(gca(),x,y,"fill","s") 528 x = rand(1,n);
443 </scilab:image> 529 y = rand(1,n);
444 <para> 530 mAreas = 10.^grand(1,n,"unf",1,2.8);
445 Modify scatter plot after creation 531
446 </para> 532 clf
447 <programlisting role="example"><![CDATA[ 533 p = scatter(x, y, mAreas, "yel", "fill", "markerEdgeColor", "red")
448// x and y initialisation 534
449t = linspace(0,1,200); 535 // Post-processing
450x = t .* cos(10*%pi*t); 536 k = mAreas<median(mAreas)*2;
451y = t .* sin(10*%pi*t); 537 bg = ones(1,n) * p.mark_background;
452// create 2D scatter plot 538 bg(k) = color("orange");
453p = scatter(x, y); 539 p.mark_background = bg;
454 ]]></programlisting> 540
455 <scilab:image> 541 gcf().axes_size = [450 300];
456 t = linspace(0,25,200) 542 ]]></scilab:image>
457 x = t.*cos(t)
458 y = t.*sin(t)
459 p = scatter(x,y,t)
460 </scilab:image>
461 <programlisting role="example"><![CDATA[
462// modify polyline
463p.thickness = 0.5;
464p.mark_foreground = color("darkblue");
465p.mark_background = color("darkcyan");
466 ]]></programlisting>
467 <scilab:image>
468 t = linspace(0,25,200)
469 x = t.*cos(t)
470 y = t.*sin(t)
471 p = scatter(x,y,t)
472 p.thickness = 0.5
473 p.mark_foreground = color("darkblue")
474 p.mark_background = color("darkcyan")
475 </scilab:image>
476 </refsection> 543 </refsection>
477 <refsection role="see also"> 544 <refsection role="see also">
478 <title>See also</title> 545 <title>See also</title>
@@ -503,7 +570,22 @@ p.mark_background = color("darkcyan");
503 <revision> 570 <revision>
504 <revnumber>6.0.0</revnumber> 571 <revnumber>6.0.0</revnumber>
505 <revremark> 572 <revremark>
506 Function <function>scatter</function> introduced. 573 Function scatter() introduced.
574 </revremark>
575 </revision>
576 <revision>
577 <revnumber>6.1.0</revnumber>
578 <revremark>
579 <itemizedlist>
580 <listitem>
581 Colors can be specified as well with their "#RRGGBB" hexadecimal
582 standard code, or their index in the color map.
583 </listitem>
584 <listitem>
585 Options <emphasis>SmallOnTop</emphasis> and
586 <emphasis>"datatips"</emphasis> added.
587 </listitem>
588 </itemizedlist>
507 </revremark> 589 </revremark>
508 </revision> 590 </revision>
509 </revhistory> 591 </revhistory>
diff --git a/scilab/modules/graphics/help/en_US/3d_plot/scatter3d.xml b/scilab/modules/graphics/help/en_US/3d_plot/scatter3d.xml
index 44bc01c..77d1ecd 100644
--- a/scilab/modules/graphics/help/en_US/3d_plot/scatter3d.xml
+++ b/scilab/modules/graphics/help/en_US/3d_plot/scatter3d.xml
@@ -2,8 +2,8 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch 4 * Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -23,13 +23,20 @@
23 </refnamediv> 23 </refnamediv>
24 <refnamediv xml:id="scatter3"> 24 <refnamediv xml:id="scatter3">
25 <refname>scatter3</refname> 25 <refname>scatter3</refname>
26 <refpurpose>3D scatter plot (obsolete)</refpurpose> 26 <refpurpose>3D scatter plot <emphasis role="bold">(obsolete)</emphasis></refpurpose>
27 </refnamediv> 27 </refnamediv>
28 <refsynopsisdiv> 28 <refsynopsisdiv>
29 <title>Syntax</title> 29 <title>Syntax</title>
30 <synopsis> 30 <synopsis>
31 polyline = scatter3d(x, y, z, msizes, mcolors, "fill", marker, &lt;marker_property,value&gt;) 31 scatter3d() // Example
32 polyline = scatter3d(axes_handle,...) 32 scatter3d(x, y, z)
33 scatter3d(x, y, z, msizes)
34 scatter3d(x, y, z, msizes, mcolors)
35 scatter3d(.., "fill")
36 scatter3d(.., "fill", marker)
37 scatter3d(..., &lt;marker_property, value>)
38 scatter3d(axes, ..)
39 polyline = scatter3d(..)
33 </synopsis> 40 </synopsis>
34 </refsynopsisdiv> 41 </refsynopsisdiv>
35 <refsection> 42 <refsection>
@@ -46,16 +53,28 @@
46 </listitem> 53 </listitem>
47 </varlistentry> 54 </varlistentry>
48 <varlistentry> 55 <varlistentry>
56 <term>axes</term>
57 <listitem>
58 Handle of the graphical axes in which the scatter plot must be drawn.
59 By default, the current axes is targeted.
60 <para/>
61 </listitem>
62 </varlistentry>
63 <varlistentry>
64 <term>polyline</term>
65 <listitem>
66 Handle of the created polyline.
67 <para/>
68 </listitem>
69 </varlistentry>
70 <varlistentry>
49 <term>msizes</term> 71 <term>msizes</term>
50 <listitem> 72 <listitem>
51 <para> 73 <para>
52 Specifying the sizes of the markers. 74 Sizes of the markers, as of the area of the circle surrounding the marker,
53 To plot each marker with equal size, specify <varname>msizes</varname> as a scalar. 75 in point-square. Default value = 36. If it is scalar,
54 To plot each marker with a different size, specify <varname>msizes</varname> 76 the same size is used for all markers. Otherwise <varname>msizes</varname>
55 as a vector with n components. 77 and <varname>x</varname> must have the same number of elements.
56 The units for <varname>msizes</varname> is points squared, with a default
57 value of 36 points squared.
58 The size equals the area of the circle surrounding the marker.
59 </para> 78 </para>
60 </listitem> 79 </listitem>
61 </varlistentry> 80 </varlistentry>
@@ -63,18 +82,35 @@
63 <term>mcolors</term> 82 <term>mcolors</term>
64 <listitem> 83 <listitem>
65 <para> 84 <para>
66 Specifying the colors of the markers. 85 Colors of markers. If it is scalar, the same color is used for all markers.
67 To plot each marker with the same color, specify <varname>mcolors</varname> 86 Otherwise, <varname>mcolors</varname> and <varname>x</varname> must have
68 as a string representing a known color: see <link linkend="color_list">color_list</link>. 87 the same number of elements.
69 A color can also be specified by a vector of 3 RGB values. 88 </para>
70 RGB values correspond to red, green and blue intensity between 0 and 1. 89 <para>
71 To plot each marker with a different color, specify <varname>mcolors</varname> 90 The same color is used for filling the body and drawing the edge of markers.
72 as a vector with n components. 91 </para>
92 <para>
73 The values of <varname>mcolors</varname> are linearly mapped to the colors 93 The values of <varname>mcolors</varname> are linearly mapped to the colors
74 in the current colormap. 94 in the current colormap.
75 Colors can also by specified by a matrix of RGB values or a vector of 95 </para>
76 strings representing known colors. 96 <para>
77 A matrix of RGB values has 3 columns and n rows. 97 A color can be specified by one of the following:
98 <itemizedlist>
99 <listitem>
100 Its name, among the predefined names colors
101 (see the <link linkend="color_list">color_list</link>).
102 </listitem>
103 <listitem>
104 Its standard hexadecimal RGB code as a string, like "#A532FB".
105 </listitem>
106 <listitem>
107 A matrix of RGB values with 3 columns and n rows, with Red Green and
108 Blue intensities in [0,1].
109 </listitem>
110 <listitem>
111 Its index in the current color map
112 </listitem>
113 </itemizedlist>
78 The default color is "blue". 114 The default color is "blue".
79 </para> 115 </para>
80 </listitem> 116 </listitem>
@@ -83,10 +119,9 @@
83 <term>"fill"</term> 119 <term>"fill"</term>
84 <listitem> 120 <listitem>
85 <para> 121 <para>
86 This string indicates that the markers are filled with some colors. 122 By default, only the edge of markers is drawn, unless this keyword or the
87 By default the filling colors of markers are the same as their shape ones. 123 <varname>"markerFaceColor"</varname> or
88 However, both colors can be set independently by using the properties 124 <varname>"markerBackgroundColor"</varname> properties are set.
89 <literal>"markerFaceColor"</literal> or <literal>"markerBackgroundColor"</literal>.
90 </para> 125 </para>
91 </listitem> 126 </listitem>
92 </varlistentry> 127 </varlistentry>
@@ -94,9 +129,8 @@
94 <term>marker</term> 129 <term>marker</term>
95 <listitem> 130 <listitem>
96 <para> 131 <para>
97 Select the type of the marker. The same marker shape is used for all 132 Selects the shape of the markers. The same shape is used for all
98 specified points. 133 specified points. The figure below shows the 15 different marker shapes.
99 The figure below shows the 15 different marker types.
100 </para> 134 </para>
101 <para> 135 <para>
102 <inlinemediaobject> 136 <inlinemediaobject>
@@ -106,192 +140,144 @@
106 </inlinemediaobject> 140 </inlinemediaobject>
107 </para> 141 </para>
108 <para> 142 <para>
109 Marker types are specified by strings: see the table below. 143 Each marker shape is specified either by its index (list above) or by
144 its string symbol (table below).
110 </para> 145 </para>
111 <para> 146 <para>
112 <informaltable border="1"> 147 <informaltable border="1">
113 <tr> 148 <tr><td>Index</td>
114 <td> 149 <td>String</td>
115 String 150 <td>Marker type</td>
116 </td>
117 <td>
118 Marker type
119 </td>
120 </tr> 151 </tr>
121 <tr> 152 <tr>
122 <td> 153 <td>0</td>
123 <literal>"."</literal> 154 <td><literal>"."</literal></td>
124 </td>
125 <td>Point</td> 155 <td>Point</td>
126 </tr> 156 </tr>
127 <tr> 157 <tr>
128 <td> 158 <td>1</td>
129 <literal>"+"</literal> 159 <td><literal>"+"</literal></td>
130 </td>
131 <td>Plus sign</td> 160 <td>Plus sign</td>
132 </tr> 161 </tr>
133 <tr> 162 <tr>
134 <td> 163 <td>2</td>
135 <literal>"x"</literal> 164 <td><literal>"x"</literal></td>
136 </td>
137 <td>Cross</td> 165 <td>Cross</td>
138 </tr> 166 </tr>
139 <tr> 167 <tr>
140 <td> 168 <td>3</td>
141 <literal>"circle plus"</literal> 169 <td><literal>"circle plus"</literal></td>
142 </td>
143 <td>Circle with plus</td> 170 <td>Circle with plus</td>
144 </tr> 171 </tr>
145 <tr> 172 <tr>
146 <td> 173 <td>4</td>
147 <literal>"filled diamond"</literal> 174 <td><literal>"filled diamond"</literal></td>
148 </td>
149 <td>Filled diamond</td> 175 <td>Filled diamond</td>
150 </tr> 176 </tr>
151 <tr> 177 <tr>
152 <td> 178 <td>5</td>
153 <literal>"d"</literal> or 179 <td><literal>"d"</literal> or <literal>"diamond"</literal></td>
154 <literal>"diamond"</literal>
155 </td>
156 <td>Diamond</td> 180 <td>Diamond</td>
157 </tr> 181 </tr>
158 <tr> 182 <tr>
159 <td> 183 <td>6</td>
160 <literal>"^"</literal> 184 <td><literal>"^"</literal></td>
161 </td>
162 <td>Upward-pointing triangle</td> 185 <td>Upward-pointing triangle</td>
163 </tr> 186 </tr>
164 <tr> 187 <tr>
165 <td> 188 <td>7</td>
166 <literal>"v"</literal> 189 <td><literal>"v"</literal></td>
167 </td>
168 <td>Downward-pointing triangle</td> 190 <td>Downward-pointing triangle</td>
169 </tr> 191 </tr>
170 <tr> 192 <tr>
171 <td> 193 <td>8</td>
172 <literal>"diamond plus"</literal> 194 <td><literal>"diamond plus"</literal></td>
173 </td>
174 <td>Diamond with plus</td> 195 <td>Diamond with plus</td>
175 </tr> 196 </tr>
176 <tr> 197 <tr>
177 <td> 198 <td>9</td>
178 <literal>"o"</literal> 199 <td><literal>"o"</literal></td>
179 </td>
180 <td>Circle (default)</td> 200 <td>Circle (default)</td>
181 </tr> 201 </tr>
182 <tr> 202 <tr>
183 <td> 203 <td>10</td>
184 <literal>"*"</literal> 204 <td><literal>"*"</literal></td>
185 </td>
186 <td>Asterisk</td> 205 <td>Asterisk</td>
187 </tr> 206 </tr>
188 <tr> 207 <tr>
189 <td> 208 <td>11</td>
190 <literal>"s"</literal> or 209 <td><literal>"s"</literal> or <literal>"square"</literal></td>
191 <literal>"square"</literal>
192 </td>
193 <td>Square</td> 210 <td>Square</td>
194 </tr> 211 </tr>
195 <tr> 212 <tr>
196 <td> 213 <td>12</td>
197 <literal>"&gt;"</literal> 214 <td><literal>">"</literal></td>
198 </td>
199 <td>Right-pointing triangle</td> 215 <td>Right-pointing triangle</td>
200 </tr> 216 </tr>
201 <tr> 217 <tr>
202 <td> 218 <td>13</td>
203 <literal>"&lt;"</literal> 219 <td><literal>"&lt;"</literal></td>
204 </td>
205 <td>Left-pointing triangle</td> 220 <td>Left-pointing triangle</td>
206 </tr> 221 </tr>
207 <tr> 222 <tr>
208 <td> 223 <td>14</td>
209 <literal>"pentagram"</literal> or 224 <td><literal>"pentagram"</literal> or <literal>"p"</literal></td>
210 <literal>"p"</literal>
211 </td>
212 <td>Five-pointed star</td> 225 <td>Five-pointed star</td>
213 </tr> 226 </tr>
214 </informaltable> 227 </informaltable>
215 </para> 228 </para>
216 </listitem> 229 </listitem>
217 </varlistentry> 230 </varlistentry>
231 </variablelist>
232 <refsect3>
233 <title>Property &lt;Name, Value> pairs</title>
234 <para>
235 A series of property value pairs can be used to specify type, color and
236 line width of the markers.
237 </para>
238 </refsect3>
239 <variablelist>
218 <varlistentry> 240 <varlistentry>
219 <term>&lt;marker_property, value&gt;</term> 241 <term>"marker", value or "markerStyle", value</term>
220 <listitem>
221 <para>
222 A sequence of property value pairs can be used to specify type, color and
223 line width of the markers.
224 </para>
225 </listitem>
226 </varlistentry>
227 <varlistentry>
228 <term>&lt;"marker", value&gt; or &lt;"markerStyle", value&gt;</term>
229 <listitem> 242 <listitem>
230 <para> 243 <para>
231 Specify the type of the marker, see the table above. 244 Shape of the marker (index or string keyword). See the table above.
232 </para> 245 </para>
233 </listitem> 246 </listitem>
234 </varlistentry> 247 </varlistentry>
235 <varlistentry> 248 <varlistentry>
236 <term>&lt;"markerEdgeColor", value&gt; or &lt;"markerForeground", value&gt;</term> 249 <term>"markerEdgeColor", value or "markerForeground", value</term>
237 <listitem> 250 <listitem>
238 <para> 251 <para>
239 Specify the foreground color of the marker. 252 Color of the edge of markers. Colors can be specified as for
240 A color can be specified by a string representing a known color: 253 <varname>mcolors</varname>.
241 see <link linkend="color_list">color_list</link>. 254 This option supersedes <varname>mcolors</varname>.
242 A color can also be specified by a vector of 3 RGB values.
243 RGB values correspond to red, green and blue intensity between 0 and 1.
244 This option is superseded by the <varname>mcolors</varname> argument.
245 </para> 255 </para>
246 </listitem> 256 </listitem>
247 </varlistentry> 257 </varlistentry>
248 <varlistentry> 258 <varlistentry>
249 <term>&lt;"markerFaceColor", value&gt; or &lt;"markerBackground", value&gt;</term> 259 <term>"markerFaceColor",value or "markerBackground",value</term>
250 <listitem> 260 <listitem>
251 <para> 261 <para>
252 Specify the background color of the marker. 262 Color filling the body of markers. Colors can be specified as for
253 A color can be specified by a string representing a known color: 263 <varname>mcolors</varname>.
254 see <link linkend="color_list">color_list</link>. 264 This option supersedes <varname>mcolors</varname>.
255 A color can also be specified by a vector of 3 RGB values.
256 RGB values correspond to red, green and blue intensity between 0 and 1.
257 This option is superseded by argument <varname>mcolors</varname>.
258 </para> 265 </para>
259 </listitem> 266 </listitem>
260 </varlistentry> 267 </varlistentry>
261 <varlistentry> 268 <varlistentry>
262 <term>&lt;"linewidth", value&gt; or &lt;"thickness", value&gt;</term> 269 <term>"linewidth",value or "thickness",value</term>
263 <listitem> 270 <listitem>
264 <para> 271 <para>
265 Specify the thickness of the edge of the marker. 272 Specify the thickness of the edge for all markers.
266 The unit for the value is one point. 273 The unit for the value is one point.
267 </para> 274 </para>
268 </listitem> 275 </listitem>
269 </varlistentry> 276 </varlistentry>
270 <varlistentry>
271 <term>axes_handle</term>
272 <listitem>
273 <para>This optional argument forces the scatter plot to appear inside the
274 selected axes given by <literal>axes_handle</literal> rather than inside the
275 current axes, see <link linkend="gca">gca</link>.
276 </para>
277 </listitem>
278 </varlistentry>
279 <varlistentry>
280 <term>polyline</term>
281 <listitem>
282 <para>
283 Handle of the created polyline.
284 </para>
285 </listitem>
286 </varlistentry>
287 </variablelist> 277 </variablelist>
288 </refsection> 278 </refsection>
289 <refsection> 279 <refsection>
290 <title>Description</title> 280 <title>Description</title>
291 <warning>
292 <literal>scatter3()</literal> is obsolete and will be removed in Scilab 6.1.x.
293 Please use <literal>scatter3d()</literal> instead.
294 </warning>
295 <para> 281 <para>
296 <literal>scatter3d(x,y,z)</literal> creates a scatter plot with markers at the locations 282 <literal>scatter3d(x,y,z)</literal> creates a scatter plot with markers at the locations
297 specified by <varname>x</varname>, <varname>y</varname>, and <varname>z</varname>. 283 specified by <varname>x</varname>, <varname>y</varname>, and <varname>z</varname>.
@@ -308,8 +294,9 @@
308 <note> 294 <note>
309 <itemizedlist> 295 <itemizedlist>
310 <listitem> 296 <listitem>
311 To skip an argument, just replace it with <literal>[]</literal> as in 297 To skip an argument, just .. skip it, or replace it with <literal>[]</literal>,
312 <literal>scatter3d(x,y,z,[],mcolors)</literal>. 298 like in <literal>scatter3d(x,y,z, , mcolors)</literal> or in
299 <literal>scatter3d(x,y,z,[], mcolors)</literal>.
313 </listitem> 300 </listitem>
314 <listitem> 301 <listitem>
315 When the axes is rotated, the markers are automatically rotated as well in order 302 When the axes is rotated, the markers are automatically rotated as well in order
@@ -324,216 +311,243 @@
324 Create 3D scatter plot 311 Create 3D scatter plot
325 </para> 312 </para>
326 <programlisting role="example"><![CDATA[ 313 <programlisting role="example"><![CDATA[
327// x, y and z initialisation 314// Data: points on an hemisphere
328t = 1:200; 315azimuth = 0:12:359;
329x = t .* cos(t) .* sin(t); 316latitude = 3:12:89;
330y = t .* sin(t) .* sin(t); 317[az, lat] = ndgrid(azimuth, latitude);
331z = t .* cos(t); 318r = cosd(lat);
332// create 3D scatter plot 319x = 1.1*cosd(az+lat/3) .* r;
333scatter3d(x, y, z); 320y = 1.1*sind(az+lat/3) .* r;
334// modify rotation angles 321z = sind(lat);
335gca().rotation_angles = [60, 45]; 322
323clf
324gcf().color_map = parulacolormap(50);
325
326subplot(1,2,1) // Plot on the left
327// Markers size according to r
328scatter3d(x, y, z, r.^2*80);
329
330subplot(1,2,2) // Plot on the right
331options = list("fill", "markerEdgeColor","red","thickness",0.5);
332mcolors = az; // + colors according to the azimuth
333scatter3d(x, y, z, r.^2*80, mcolors, options(:));
334
335// Tuning axes rendering
336gcf().children.grid = [1 1 1]*color("grey50");
337gcf().children.rotation_angles = [83 -20];
336 ]]></programlisting> 338 ]]></programlisting>
337 <scilab:image> 339 <scilab:image>
338 t = 1:200 340 // Data: points on an hemisphere
339 x = t.*cos(t).*sin(t) 341 azimuth = 0:12:359;
340 y = t.*sin(t).*sin(t) 342 latitude = 3:12:89;
341 z = t.*cos(t) 343 [az, lat] = ndgrid(azimuth, latitude);
342 scatter3d(x,y,z) 344 r = cosd(lat);
343 gca().rotation_angles = [60, 45]; 345 x = 1.1*cosd(az+lat/3) .* r;
346 y = 1.1*sind(az+lat/3) .* r;
347 z = sind(lat);
348
349 clf
350 gcf().color_map = parulacolormap(50);
351
352 subplot(1,2,1) // Plot on the left
353 // Markers size according to r
354 scatter3d(x, y, z, r.^2*80);
355
356 subplot(1,2,2) // Plot on the right
357 options = list("fill", "markerEdgeColor","red","thickness",0.5);
358 mcolors = az; // + colors according to the azimuth
359 scatter3d(x, y, z, r.^2*80, mcolors, options(:));
360
361 // Tuning axes rendering
362 gcf().children.grid = [1 1 1]*color("grey50");
363 gcf().children.rotation_angles = [83 -20];
364 gcf().axes_size = [750 400];
344 </scilab:image> 365 </scilab:image>
345 <para> 366 <para>
346 Vary marker size 367 Styling the markers:
347 </para> 368 </para>
348 <programlisting role="example"><![CDATA[ 369 <programlisting role="example"><![CDATA[
349// x, y and z initialisation 370// Data
350t = 1:200; 371z = linspace(0, 25, 150);
351x = t .* cos(t) .* sin(t);
352y = t .* sin(t) .* sin(t);
353z = t .* cos(t);
354// size according to radius
355s = linspace(50, 1, length(t));
356// create 3D scatter plot
357scatter3d(x, y, z, s);
358// modify rotation angles
359gca().rotation_angles = [60, 45];
360 ]]></programlisting>
361 <scilab:image>
362 t = 1:200
363 x = t .* cos(t) .* sin(t)
364 y = t .* sin(t) .* sin(t)
365 z = t .* cos(t)
366 s = linspace(50, 1, length(t))
367 scatter3d(x, y, z, s)
368 gca().rotation_angles = [60, 45];
369 </scilab:image>
370 <para>
371 Vary marker size and color
372 </para>
373 <programlisting role="example"><![CDATA[
374// x, y and z initialisation
375t = 1:200;
376x = t .* cos(t) .* sin(t);
377y = t .* sin(t) .* sin(t);
378z = t .* cos(t);
379// size according to radius
380s = linspace(50, 1, length(t));
381// set color map
382gcf().color_map = coolcolormap(64);
383// color according to radius
384c = t;
385// create 3D scatter plot
386scatter3d(x, y, z, s, c);
387// modify rotation angles
388gca().rotation_angles = [60, 45];
389 ]]></programlisting>
390 <scilab:image>
391 t = 1:200
392 x = t.*cos(t).*sin(t)
393 y = t.*sin(t).*sin(t)
394 z = t.*cos(t)
395 s = linspace(50,1,length(t))
396 gcf().color_map = coolcolormap(64);
397 c = t
398 scatter3d(x,y,z,s,c)
399 gca().rotation_angles = [60, 45];
400 </scilab:image>
401 <para>
402 Fill the markers
403 </para>
404 <programlisting role="example"><![CDATA[
405// x, y and z initialisation
406z = linspace(0, 25, 200);
407x = z .* cos(z);
408y = z .* sin(z);
409// create 3D scatter plot
410scatter3d(x, y, z, "fill");
411// modify rotation angles
412gca().rotation_angles = [60, 45];
413 ]]></programlisting>
414 <scilab:image>
415 z = linspace(0,25,200)
416 x = z.*cos(z)
417 y = z.*sin(z)
418 scatter3d(x,y,z,"fill")
419 gca().rotation_angles = [60, 45];
420 </scilab:image>
421 <para>
422 Specify marker symbol
423 </para>
424 <programlisting role="example"><![CDATA[
425// x, y and z initialisation
426z = linspace(0, 25, 200);
427x = z .* cos(z); 372x = z .* cos(z);
428y = z .* sin(z); 373y = z .* sin(z);
429// create 3D scatter plot 374
375subplot(2,2,1)
376scatter3d(x, y, z)
377
378// Fill the markers
379subplot(2,2,2)
380scatter3d(x, y, z, , "turquoise", "fill")
381
382// Choose another marker shape
383subplot(2,2,3)
430scatter3d(x, y, z, "*"); 384scatter3d(x, y, z, "*");
431// modify rotation angles 385
432gca().rotation_angles = [60, 45]; 386// Customize the markers colors
433 ]]></programlisting> 387subplot(2,2,4)
434 <scilab:image>
435 z = linspace(0,25,200)
436 x = z.*cos(z)
437 y = z.*sin(z)
438 scatter3d(x,y,z,"*")
439 gca().rotation_angles = [60,45];
440 </scilab:image>
441 <para>
442 Change marker edge and face color
443 </para>
444 <programlisting role="example"><![CDATA[
445// x, y and z initialisation
446z = linspace(0, 25, 200);
447x = z .* cos(z);
448y = z .* sin(z);
449// create 3D scatter plot
450scatter3d(x, y, z,... 388scatter3d(x, y, z,...
451 "markerEdgeColor", "black",... 389 "markerEdgeColor", [1 0 0],...
452 "markerFaceColor", [0 .8 .8]); 390 "markerFaceColor", "yellow");
453// modify rotation angles 391
454gca().rotation_angles = [60, 45]; 392// Tune the 3D orientation of all axes
393gcf().children.rotation_angles = [65 35];
455 ]]></programlisting> 394 ]]></programlisting>
456 <scilab:image> 395 <scilab:image>
457 z = linspace(0,25,200) 396 // Data
458 x = z.*cos(z) 397 z = linspace(0, 25, 150);
459 y = z.*sin(z) 398 x = z .* cos(z);
460 scatter3d(x,y,z,... 399 y = z .* sin(z);
461 "markerEdgeColor","black",... 400
462 "markerFaceColor",[0 .8 .8]) 401 subplot(2,2,1)
463 gca().rotation_angles = [60, 45]; 402 scatter3d(x, y, z)
403
404 // Fill the markers
405 subplot(2,2,2)
406 scatter3d(x, y, z, , "turquoise", "fill")
407
408 // Choose another marker shape
409 subplot(2,2,3)
410 scatter3d(x, y, z, "*");
411
412 // Customize the markers colors
413 subplot(2,2,4)
414 scatter3d(x, y, z,...
415 "markerEdgeColor", [1 0 0],...
416 "markerFaceColor", "yellow");
417
418 // Tune the 3D orientation of all axes
419 gcf().children.rotation_angles = [65 35];
420
421 gcf().axes_size = [750 450];
464 </scilab:image> 422 </scilab:image>
465 <para> 423 <para>
466 Specify subplot for scatter plot 424 Specify subplot for scatter plot
467 </para> 425 </para>
468 <programlisting role="example"><![CDATA[ 426 <programlisting role="example"><![CDATA[
469// x, y and z initialisation 427// Data
470n = 20; 428n = 20;
471[x, y] = meshgrid(linspace(-2, 2, n)); 429[x, y] = meshgrid(linspace(-2, 2, n));
472z = exp(-x.^2 - y.^2); 430z = exp(-x.^2 - y.^2);
473// create 3D scatter subplot 431
474subplot(2,1,1)
475scatter3d(gca(), x(:), y(:), z(:));
476// modify rotation angles
477gca().rotation_angles = [60,45];
478// create 3D scatter subplot
479subplot(2,1,2) 432subplot(2,1,2)
480scatter3d(gca(), x(:), y(:), z(:), "markerFaceColor", [0 .8 .8]); 433axes2 = gca();
481// modify rotation angles 434subplot(2,1,1)
482gca().rotation_angles = [60,45]; 435
436scatter3d(x, y, z);
437scatter3d(axes2, x(:), y(:), z(:), "markerFaceColor", [0 .8 .8]);
438
439// Tune axes view
440Axes = gcf().children;
441Axes.rotation_angles = [60,45];
442Axes.grid = [1 1 1]*color("grey50");
483 ]]></programlisting> 443 ]]></programlisting>
484 <scilab:image> 444 <scilab:image>
485 n = 20 445 // Data
486 [x,y] = meshgrid(linspace(-2,2,n)) 446 n = 20;
487 z = exp(-x.^2 - y.^2) 447 [x, y] = meshgrid(linspace(-2, 2, n));
488 subplot(2,1,1) 448 z = exp(-x.^2 - y.^2);
489 scatter3d(gca(), x(:), y(:), z(:)) 449
490 gca().rotation_angles = [60, 45];
491 subplot(2,1,2) 450 subplot(2,1,2)
492 scatter3d(gca(),x(:),y(:),z(:),"markerFaceColor",[0 .8 .8]) 451 axes2 = gca();
493 gca().rotation_angles = [60, 45]; 452 subplot(2,1,1)
453
454 scatter3d(x, y, z);
455 scatter3d(axes2, x(:), y(:), z(:), "markerFaceColor", [0 .8 .8]);
456
457 // Tune axes view
458 Axes = gcf().children;
459 Axes.rotation_angles = [60,45];
460 Axes.grid = [1 1 1]*color("grey50");
461
462 gcf().axes_size = [500 350];
494 </scilab:image> 463 </scilab:image>
495 <para> 464 <para>
496 Modify scatter plot after creation 465 <emphasis role="bold">Use the handle to post-process the scatter plot</emphasis>:
497 </para> 466 </para>
498 <programlisting role="example"><![CDATA[ 467 <programlisting role="example"><![CDATA[
499// x, y and z initialisation 468// Data: points on an hemisphere
500t = 1:200; 469azimuth = 0:12:359;
501x = t .* cos(t) .* sin(t); 470latitude = 3:12:89;
502y = t .* sin(t) .* sin(t); 471[az, lat] = ndgrid(azimuth, latitude);
503z = t .* cos(t); 472r = cosd(lat);
504// size according to radius 473x = 1.1*cosd(az+lat/3) .* r;
505s = linspace(50, 1, length(t)); 474y = 1.1*sind(az+lat/3) .* r;
506// create 3D scatter plot 475z = sind(lat);
507scatter3d(x, y, z, s); 476
508// modify rotation angles 477clf
509gca().rotation_angles = [60,45]; 478
479subplot(1,2,1)
480scatter3d(x, y, z, r.^2*80);
481title("Initial plot", "fontsize",3)
482
483subplot(1,2,2)
484p = scatter3d(x, y, z, r.^2*80); // The same
485title("Final plot", "fontsize",3)
486
487// Let's post-process it through the handle:
488
489// 1) Let's set all markers at y < 0 in yellow, and others in orange
490np = size(p.data,1); // number of points
491tmp = ones(1,np) * color("orange");
492tmp(p.data(:,2)<0) = color("yellow");
493p.mark_background = tmp;
494
495// 2) and markers at x > 0 1.4 smaller than other
496tmp = p.data(:,1) > 0;
497p.mark_size(tmp) = p.mark_size(tmp)/1.4;
498
499// 3) Changing the edge color and thickness for all markers
500p.mark_foreground = color("red");
501p.thickness = 0.5;
502
503// Tuning axes
504Axes = gcf().children;
505Axes.rotation_angles = [82, -40];
506Axes.grid = [1 1 1]*color("grey60");
510 ]]></programlisting> 507 ]]></programlisting>
511 <scilab:image> 508 <scilab:image><![CDATA[
512 t = 1:200 509 // Data: points on an hemisphere
513 x = t.*cos(t).*sin(t) 510 azimuth = 0:12:359;
514 y = t.*sin(t).*sin(t) 511 latitude = 3:12:89;
515 z = t.*cos(t) 512 [az, lat] = ndgrid(azimuth, latitude);
516 s = linspace(50,1,length(t)) 513 r = cosd(lat);
517 p = scatter3d(x,y,z,s) 514 x = 1.1*cosd(az+lat/3) .* r;
518 gca().rotation_angles = [60,45]; 515 y = 1.1*sind(az+lat/3) .* r;
519 </scilab:image> 516 z = sind(lat);
520 <programlisting role="example"><![CDATA[ 517
521// modify polyline 518 clf
522p.mark_foreground = color(0.5, 0, 0); 519
523p.mark_background = color(0.5, 0.5, 0); 520 subplot(1,2,1)
524 ]]></programlisting> 521 scatter3d(x, y, z, r.^2*80);
525 <scilab:image> 522 title("Initial plot", "fontsize",3)
526 t = 1:200 523
527 x = t.*cos(t).*sin(t) 524 subplot(1,2,2)
528 y = t.*sin(t).*sin(t) 525 p = scatter3d(x, y, z, r.^2*80); // The same
529 z = t.*cos(t) 526 title("Final plot", "fontsize",3)
530 s = linspace(50,1,length(t)) 527
531 p = scatter3d(x,y,z,s) 528 // Let's post-process it through the handle:
532 set(gca(),"rotation_angles",[60,45]) 529
533 // modify polyline 530 // 1) Let's set all markers at y < 0 in yellow, and others in orange
534 p.mark_foreground = color(0.5, 0, 0) 531 np = size(p.data,1); // number of points
535 p.mark_background = color(0.5, 0.5, 0) 532 tmp = ones(1,np) * color("orange");
536 </scilab:image> 533 tmp(p.data(:,2)<0) = color("yellow");
534 p.mark_background = tmp;
535
536 // 2) and markers at x > 0 1.4 smaller than other
537 tmp = p.data(:,1) > 0;
538 p.mark_size(tmp) = p.mark_size(tmp)/1.4;
539
540 // 3) Changing the edge color and thickness for all markers
541 p.mark_foreground = color("red");
542 p.thickness = 0.5;
543
544 // Tuning axes
545 Axes = gcf().children;
546 Axes.rotation_angles = [82, -40];
547 Axes.grid = [1 1 1]*color("grey60");
548
549 gcf().axes_size = [700 350];
550 ]]></scilab:image>
537 </refsection> 551 </refsection>
538 <refsection role="see also"> 552 <refsection role="see also">
539 <title>See also</title> 553 <title>See also</title>
@@ -564,7 +578,21 @@ p.mark_background = color(0.5, 0.5, 0);
564 <revision> 578 <revision>
565 <revnumber>6.0.0</revnumber> 579 <revnumber>6.0.0</revnumber>
566 <revremark> 580 <revremark>
567 Function <function>scatter3d</function> introduced. 581 Function scatter3() introduced.
582 </revremark>
583 </revision>
584 <revision>
585 <revnumber>6.1.0</revnumber>
586 <revremark>
587 <itemizedlist>
588 <listitem>
589 Function scatter3() set obsolete. scatter3d() is introduced.
590 </listitem>
591 <listitem>
592 Colors can be specified as well with their "#RRGGBB" hexadecimal
593 standard code or their index in the color map.
594 </listitem>
595 </itemizedlist>
568 </revremark> 596 </revremark>
569 </revision> 597 </revision>
570 </revhistory> 598 </revhistory>
diff --git a/scilab/modules/graphics/macros/scatter.sci b/scilab/modules/graphics/macros/scatter.sci
index d2cda48..d22413b 100644
--- a/scilab/modules/graphics/macros/scatter.sci
+++ b/scilab/modules/graphics/macros/scatter.sci
@@ -1,7 +1,7 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch <juergen.koch@hs-esslingen.de> 2// Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch <juergen.koch@hs-esslingen.de>
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises 3// Copyright (C) 2012 - 2016 - Scilab Enterprises
4// Copyright (C) 2018 - 2020 - Samuel GOUGEON
5// 5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0, 6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1. 7// pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -10,47 +10,40 @@
10// For more information, see the COPYING file which you should have received 10// For more information, see the COPYING file which you should have received
11// along with this program. 11// along with this program.
12 12
13function polyLine = scatter(varargin) 13function varargout = scatter(varargin)
14 14
15 polyLine = 0; 15 polyLine = 0;
16 [lhs,rhs] = argn(0); 16 [lhs,rhs] = argn(0);
17 17
18 // Example:
18 if ~rhs 19 if ~rhs
19 clf; 20 r = gca().axes_bounds; delete(gca()); xsetech(r);
20 t = linspace(0,25,200); 21 t = linspace(0, 25, 200);
21 x = t.*cos(t); 22 x = t .* cos(t);
22 y = t.*sin(t); 23 y = t .* sin(t);
23 polyLine = scatter(x,y,t,t,"fill","markerEdgeColor","darkblue") 24 polyLine = scatter(x, y, t, t, "fill", "markerEdgeColor", "darkblue")
24 return; 25 if lhs > 0
26 varargout = list(polyLine);
27 end
28 return
25 end 29 end
26 30
27 //detect and set the current axes now: 31 // Minimal arguments checking to call scatter3(), and call it.
28 n = size(varargin); 32 msg = _("%s: Wrong number of input arguments: At least %d expected.\n");
29 if type(varargin(1)) == 9 then // graphic handle 33 if type(varargin(1))==9 then // graphic handle
30 hdle = varargin(1); 34 if rhs < 3
31 if hdle.type == "Axes" then 35 error(msprintf(msg, "scatter", 3));
32 if n < 3 then
33 warning("Not enough input arguments.")
34 return;
35 else
36 axesHandle = varargin(1);
37 X = varargin(2);
38 Y = varargin(3);
39 polyLine = scatter3d(axesHandle,X,Y,[],varargin(4:n));
40 end
41 else
42 warning("Handle should be an Axes handle.")
43 return;
44 end 36 end
37 _from_Scatter_ = 1 // calling flag = shift of argins (for argins ranks in error msgs)
38 polyLine = scatter3d(varargin(1:3), [], varargin(4:$));
45 else 39 else
46 if size(varargin) < 2 then 40 if rhs < 2
47 warning("Not enough input arguments.") 41 error(msprintf(msg, "scatter", 2))
48 return;
49 else
50 X = varargin(1);
51 Y = varargin(2);
52 polyLine = scatter3d(X,Y,[],varargin(3:n));
53 end 42 end
43 _from_Scatter_ = %eps/4
44 polyLine = scatter3d(gca(), varargin(1:2), [], varargin(3:$));
45 end
46 if lhs > 0
47 varargout = list(polyLine);
54 end 48 end
55
56endfunction 49endfunction
diff --git a/scilab/modules/graphics/macros/scatter3d.sci b/scilab/modules/graphics/macros/scatter3d.sci
index 620504f..2f3df8d 100644
--- a/scilab/modules/graphics/macros/scatter3d.sci
+++ b/scilab/modules/graphics/macros/scatter3d.sci
@@ -1,7 +1,7 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch <juergen.koch@hs-esslingen.de> 2// Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch <juergen.koch@hs-esslingen.de>
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises 3// Copyright (C) 2012 - 2016 - Scilab Enterprises
4// Copyright (C) 2018 - 2020 - Samuel GOUGEON
5// 5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0, 6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1. 7// pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -10,429 +10,498 @@
10// For more information, see the COPYING file which you should have received 10// For more information, see the COPYING file which you should have received
11// along with this program. 11// along with this program.
12 12
13function polyLine = scatter3d(varargin) 13function varargout = scatter3d(varargin)
14 14
15 polyLine = 0; 15 polyLine = 0;
16 [lhs,rhs] = argn(0); 16 [lhs, rhs] = argn(0);
17 fname = "scatter3d";
18 FS = 0 // For argins shift in error messages, to substract from argin rank after Z
19 if isdef("_from_Scatter_") then
20 fname = "scatter";
21 FS = 1 // FromScatter
22 end
17 23
24 // Example 3D
25 // ----------
18 if ~rhs 26 if ~rhs
19 clf; 27 r = gca().axes_bounds; delete(gca()); xsetech(r);
20 z = linspace(0,25,200); 28 z = linspace(0,25,200);
21 x = z.*cos(z); 29 x = z .* cos(z);
22 y = z.*sin(z); 30 y = z .* sin(z);
23 polyLine = scatter3d(x,y,z,z,z,"fill","markerEdgeColor","darkblue"); 31 polyLine = scatter3d(x,y,z,10+z.^1.2,z,"fill","markerEdgeColor","darkblue");
24 set(gca(),"rotation_angles",[60,45]) 32 set(gca(),"rotation_angles",[60,45])
25 return; 33 if lhs > 0
34 varargout = list(polyLine)
35 end
36 return
26 end 37 end
27 38
28 //detect and set the current axes now: 39 // PARSING, CHECKING and INITIALIZING MANDATORY ARGUMENTS
29 if type(varargin(1)) == 9 then // graphic handle 40 // ------------------------------------------------------
30 hdle = varargin(1); 41 // graphic handle
31 if hdle.type == "Axes" then 42 // nh = 1 if primary call with argin#1 = axes, 0 otherwise
32 if size(varargin) < 4 then 43 if type(varargin(1)) == 9 then
33 warning("Not enough input arguments.") 44 axesHandle = varargin(1);
34 return; 45 if axesHandle.type ~= "Axes"
35 else 46 msg = _("%s: Argument #%d: Wrong type of graphic handle: ''%s'' expected.\n");
36 axesHandle = varargin(1); 47 error(msprintf(msg, fname, 1, "Axes"));
37 X = varargin(2);
38 Y = varargin(3);
39 Z = varargin(4);
40 nextArgin = 5;
41 end
42 else
43 warning("Handle should be an Axes handle.")
44 return;
45 end 48 end
46 else 49 varargin(1) = null()
47 if size(varargin) < 3 then 50 if FS==1
48 warning("Not enough input arguments.") 51 nh = floor(_from_Scatter_)
49 return;
50 else 52 else
51 axesHandle = []; 53 nh = 1
52 X = varargin(1);
53 Y = varargin(2);
54 Z = varargin(3);
55 nextArgin = 4;
56 end 54 end
55 else
56 nh = 0
57 axesHandle = gca();
57 end 58 end
58 59 // Number of input arguments
59 if (isempty(X) & isempty(Y) & isempty(Z)) then 60 if length(varargin) < 3 then // should not occur from scatter() call
60 // nothing has to be done 61 msg = _("%s: Wrong number of input arguments: At least %d expected.\n")
61 return; 62 error(msprintf(msg, fname, 3+nh))
62 end 63 end
64 // Now we know that at least the 3 next argins are defined
65 iarg = nh + 1 // rank of next argin
63 66
64 if ( isempty(Z) ) then 67 // X:
65 if (~isvector(X) | ~isvector(Y) | size(X) ~= size(Y)) then 68 X = varargin(1);
66 warning("X and Y must be vectors of the same length.") 69 if ~or(type(X)==[1 5]) | ~isreal(X,0)
67 return; 70 msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
68 end 71 error(msprintf(msg, fname, iarg))
69 else 72 else
70 if (~isvector(X) | ~isvector(Y) | ~isvector(Z) | or(size(X) ~= size(Y)) | or(size(X) ~= size(Z))) then 73 X = full(real(X(:)));
71 warning("X, Y and Z must be vectors of the same length.")
72 return;
73 end
74 end 74 end
75 varargin(1) = null();
76 iarg = iarg + 1
75 77
76 n = length(X); 78 // Y:
77 [S,C,thickness,markStyle,markFg,markBg,fill,scanFailed] = scatterScanVargin(varargin,nextArgin,n); 79 Y = varargin(1);
78 if (scanFailed) then 80 if ~or(type(Y)==[1 5]) | ~isreal(Y,0)
79 return; 81 msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
82 error(msprintf(msg, fname, iarg))
83 else
84 if length(Y)~=length(X) then
85 msg = _("%s: Arguments #%d and #%d: Same numbers of elements expected.\n")
86 error(msprintf(msg, fname, nh+1, iarg));
87 end
88 Y = full(real(Y(:)));
80 end 89 end
90 varargin(1) = null();
91 iarg = iarg + 1
81 92
82 f = gcf(); 93 // Z:
83 old_drawing_mode = f.immediate_drawing; 94 if ~FS then
84 f.immediate_drawing = "off"; 95 Z = varargin(1);
85 96 if ~or(type(Z)==[1 5]) | ~isreal(Z,0)
86 if isempty(Z) then 97 msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
87 if isempty(axesHandle) then 98 error(msprintf(msg, fname, iarg))
88 plot(X,Y);
89 else 99 else
90 plot(axesHandle,X,Y); 100 if length(Z)~=length(X) then
101 msg = _("%s: Arguments #%d and #%d: Same numbers of elements expected.\n")
102 error(msprintf(msg, fname, nh+1, iarg));
103 end
104 Z = full(real(Z(:)));
91 end 105 end
92 currentEntity = gce(); 106 iarg = iarg + 1
93 polyLine = currentEntity.children;
94 else 107 else
95 if isempty(axesHandle) then 108 Z = []
96 param3d(X,Y,Z);
97 else
98 set("current_axes",axesHandle)
99 param3d(X,Y,Z);
100 end
101 polyLine = gce();
102 end 109 end
110 varargin(1) = null();
103 111
104 if polyLine.Type <> "Polyline" then 112 // Empty case
105 warning("Handle should be a Polyline handle."); 113 if X==[] then
106 else 114 return
107 scatterSetPolyline(polyLine,S,C,thickness,markStyle,markFg,markBg,fill);
108
109 if ~isempty(Z) then
110 set(gca(),"cube_scaling","on");
111 set(gca(),"grid",[1 1 1]);
112 end
113 end 115 end
114 116
115 f.immediate_drawing = old_drawing_mode; 117 // List of properties names (lower case) (capital = added)
116endfunction 118 // "fill"
119 // "marker" "markerstyle" "Markstyle"
120 // "markerfacecolor" "markerbackgroundcolor"
121 // "markeredgecolor" "markerforeground" "markerbackgroundcolor"
122 // "thickness" "linewidth"
123 // Markers Text styles (available)
124 properties = ["marker" "markerstyle" "markstyle" ..
125 "markerfacecolor" "markerbackground" ..
126 "markeredgecolor" "markerforeground" ..
127 "thickness" "linewidth" "datatips"];
128 markersT = ["." "+" "x" "o" "o+" "circle plus" "d" "fd" "filled diamond" ..
129 "d+" "diamond plus" "^" "v" ">" "<" "*" "*5" "p" "pentagram" "s" "square"];
130 // Markers Numerical codes styles (available)
131 markersN = [ 0 1 2 9 3 3 5 4 4 ..
132 8 8 6 7 12 13 10 14 14 14 11 11];
117 133
118function [S,C,thickness,markStyle,markFg,markBg,fill,scanFailed] = scatterScanVargin(argins,nextArgin,n) 134 // PARSING, CHECKING and INITIALIZING OPTIONS
135 // ------------------------------------------
136 // Marks sizes | "fill" | marker_symbol |
137 msizes = 36; // Default markers area
138 mcolors = [];
139 markers = 9;
140 fill = %f;
141 smallOnTop = %f;
142 step = 1;
143 // Parsing step: 1 = msizes 2 = mcolors 3 = "fill"
144 // 3.5 = "smallOnTop" 4 = marker 5 = properties
119 145
120 scanFailed = %F; 146 while length(varargin) > 0 & step < 5
147 v = varargin(1)
148 if type(varargin(1))==0
149 v = []
150 end
151 select step
152 case 1
153 if type(v) == 10
154 if size(v,"*") == 1
155 v = convstr(v)
156 if v=="fill"
157 [fill, step, iarg] = (%t, 3.5, iarg+1)
158 varargin(1) = null()
159 continue
160 end
161 if v=="smallontop"
162 [fill, step, iarg] = (%t, 4, iarg+1)
163 varargin(1) = null()
164 continue
165 end
166 if or(v==markersT)
167 markers = markersN(find(v==markersT, 1))
168 [step, iarg] = (5, iarg+1)
169 varargin(1) = null()
170 continue
171 end
172 if or(v==properties)
173 step = 5
174 continue
175 end
176 msg = _("%s: Argument #%d: Wrong value. Please check allowed syntaxes and values.\n")
177 error(msprintf(msg, fname, iarg))
178 else
179 msg = _("%s: Argument #%d: Wrong value. Please check allowed syntaxes and values.\n")
180 error(msprintf(msg, fname, iarg))
181 end
121 182
122 // check for size argument 183 elseif type(v) == 1
123 S = []; 184 if v==[]
124 if size(argins) >= nextArgin then 185 [step, iarg] = (2, iarg+1)
125 if isempty(argins(nextArgin)) then 186 varargin(1) = null()
126 nextArgin = nextArgin + 1; 187 continue
127 else 188 end
128 if type(argins(nextArgin)) == 1 then 189 if ~and(isreal(v,0))
129 [n1,n2] = size(argins(nextArgin)); 190 msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
130 if (n1 == 1 & n2 == 1) | (n1 == n & n2 == 1) | (n1 == 1 & n2 == n) then 191 error(msprintf(msg, fname, iarg))
131 S = argins(nextArgin); 192 end
132 if iscolumn(S) then 193 v = real(v);
133 S = S.'; 194 if or(v<0)
195 msg = _("%s: Argument #%d: Must be >= %d.\n")
196 error(msprintf(msg, fname, iarg, 0))
197 end
198 if length(v) ~= 1 & length(v) ~= length(X)
199 msg = _("%s: Arguments #%d and #%d: Same numbers of elements expected.\n")
200 error(msprintf(msg, fname, nh+1, iarg));
201 end
202 [msizes, step, iarg] = (v, 2, iarg+1)
203 varargin(1) = null()
204
205 else
206 msg = _("%s: Argument #%d: Number(s) or text expected.\n")
207 error(msprintf(msg, fname, iarg))
208 end
209
210 case 2 // mcolors
211 if type(v)==1
212 if ~isreal(v,0)
213 msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
214 error(msprintf(msg, fname, iarg))
215 end
216 v = real(v)
217 if v==[]
218 [step, iarg] = (3, iarg+1)
219 varargin(1) = null()
220 continue
221 end
222 if length(v) == length(X)
223 // Whole colormap scaled to data
224 [cMin, cMax] = (min(v), max(v));
225 cmap = gcf().color_map;
226 numColors = size(cmap,1);
227 if ((cMax-cMin)/(cMin+cMax) > %eps) then
228 mcolors = round((numColors-1)*(v - cMin)/(cMax - cMin)) + 1;
229 else
230 mcolors = cMin;
134 end 231 end
135 nextArgin = nextArgin + 1; 232 [step, iarg] = (3, iarg+1)
136 else 233 varargin(1) = null()
137 warning("S must be a scalar or a vector of the same length as X."); 234 continue
138 scanFailed = %T;
139 return;
140 end 235 end
236 end
237 c = iscolor(v)
238 if ~or(isnan(c(:,1)))
239 if length(c) <> 1 & ~(type(c)==1 & and(size(c)==[1 3])) ..
240 & size(c,1) <> length(X)
241 msg = _("%s: Argument #%d: Wrong size: one or %d colors expected.\n")
242 error(msprintf(msg, fname, iarg, length(X)))
243 end
244 if size(c,2) > 1
245 mcolors = addcolor(c)
246 else
247 mcolors = c
248 end
249 [step, iarg] = (3, iarg+1)
250 varargin(1) = null()
251 else
252 step = 3
253 end
254
255 case 3 // "fill"
256 if type(v)==10 & size(v,"*")==1
257 v = convstr(v)
258 if v=="fill"
259 [fill, iarg] = (%t, iarg+1)
260 varargin(1) = null()
261 end
141 end 262 end
142 end 263 step = 3.5
143 end
144 264
145 // check for color argument 265 case 3.5 // "smallOnTop"
146 C = []; 266 if type(v)==10 & size(v,"*")==1
147 if size(argins) >= nextArgin then 267 v = convstr(v)
148 if isempty(argins(nextArgin)) then 268 if v=="smallontop"
149 nextArgin = nextArgin + 1; 269 [smallOnTop, iarg] = (%t, iarg+1)
150 else 270 varargin(1) = null()
151 [n1,n2] = size(argins(nextArgin)); 271 end
152 if type(argins(nextArgin)) == 1 then 272 end
153 if (n1 == n & n2 == 1) | (n1 == 1 & n2 == n) then 273 step = 4
154 C = scatterLinearColorMap(argins(nextArgin)); 274
155 nextArgin = nextArgin + 1; 275 case 4
156 elseif n1 == n & n2 == 3 then 276 // symbol or symbol id or property name
157 C = addcolor(argins(nextArgin)); 277 if size(v,"*") <> 1
158 nextArgin = nextArgin + 1; 278 msg = _("%s: Argument #%d: Scalar (1 element) expected.\n")
159 else 279 error(msprintf(msg, fname, iarg))
160 warning("C must be a vector or a matrix of the same length as X."); 280 end
161 scanFailed = %T; 281 if and(type(v) <> [1 10])
162 return; 282 msg = _("%s: Argument #%d: Number or text expected.\n")
163 end 283 error(msprintf(msg, fname, iarg))
164 if iscolumn(C) then 284 end
165 C = C.'; 285 if type(v)==1
166 end 286 tmp = find(v==markersN, 1)
167 elseif type(argins(nextArgin)) == 10 then 287 if tmp == []
168 if n1 == 1 & n2 == 1 then 288 msg = _("%s: Argument #%d: Wrong marker id.\n")
169 // check if string specifies a color 289 error(msprintf(msg, fname, iarg))
170 colorRGB = name2rgb(argins(nextArgin)); 290 end
171 if ~isempty(colorRGB) then 291 markers = v
172 C = addcolor(colorRGB/255); 292 [step, iarg] = (5, iarg+1)
173 nextArgin = nextArgin + 1; 293 varargin(1) = null()
294 else
295 v = convstr(v)
296 tmp = find(v==markersT, 1)
297 if tmp <> []
298 markers = markersN(tmp)
299 [step, iarg] = (5, iarg+1)
300 varargin(1) = null()
301 end
302 step = 5
303 end
304
305 end // select
306 end // while
307
308 // <Property, Value> pairs
309 // .......................
310 thickness = 1;
311 mBGcolors = [];
312 mFGcolors = [];
313 datatips = [];
314
315 while length(varargin) > 0
316 v = varargin(1)
317 if type(v)~=10
318 msg = _("%s: Argument #%d: keyword or property name expected.\n")
319 error(msprintf(msg, fname, iarg));
320 end
321 if size(v,"*") > 1
322 msg = _("%s: Argument #%d: Scalar (1 element) expected.\n");
323 error(msprintf(msg, fname, iarg));
324 end
325 if ~or(convstr(v)==properties)
326 msg = _("%s: Argument #%d: Unknown property name ''%s''.\n");
327 error(msprintf(msg, fname, iarg, v));
328 end
329 v = convstr(v);
330 varargin(1) = null()
331 if length(varargin)==0
332 msg = _("%s: Argument #%d: Value missing for the given property.\n")
333 error(msprintf(msg, fname, iarg))
334 end
335 val = varargin(1);
336 iarg = iarg+1;
337 if or(v==["marker" "markerstyle" "markstyle"]) then
338 if size(val,"*")~=1
339 msg = _("%s: Argument #%d: Scalar (1 element) expected.\n")
340 error(msprintf(msg, fname, iarg))
341 end
342 if type(val)==10 & ~or(convstr(val)==markersT) | ..
343 type(val)==1 & ~or(val==markersN)
344 msg = _("%s: Argument #%d: Wrong marker specification.\n")
345 error(msprintf(msg, fname, iarg))
346 end
347 if type(val)==10
348 markers = markersN(find(markersT==val));
349 else
350 markers = val
351 end
352 elseif or(v==["thickness" "linewidth"]) then
353 if size(val,"*")~=1
354 msg = _("%s: Argument #%d: Scalar (1 element) expected.\n");
355 error(msprintf(msg, fname, iarg));
356 end
357 if type(val)~=1 | ~isreal(val,0) | val<0
358 msg = _("%s: Argument #%d: Non-negative integers expected.\n");
359 error(msprintf(msg, fname, iarg));
360 end
361 thickness = val;
362 elseif or(v==["markeredgecolor" "markerforeground" ..
363 "markerfacecolor" "markerbackground" ]);
364 c = iscolor(val);
365 if or(isnan(c(:,1))) then
366 msg = _("%s: Argument #%d: Wrong color specification.\n");
367 error(msprintf(msg, fname, iarg));
368 end
369 if size(c,1)==1
370 if or(v==["markeredgecolor" "markerforeground" "markforeground"]);
371 mFGcolors = c;
372 if length(c)>1
373 mFGcolors = addcolor(c);
174 end 374 end
175 elseif (n1 == n & n2 == 1) | (n1 == 1 & n2 == n) then 375 else
176 C = addcolor(name2rgb(argins(nextArgin))/255); 376 mBGcolors = c;
177 if isempty(C) then 377 if length(c)>1
178 warning("Wrong color specified."); 378 mBGcolors = addcolor(c);
179 scanFailed = %T;
180 return;
181 else
182 nextArgin = nextArgin + 1;
183 end 379 end
184 end 380 end
381 else
382 msg = _("%s: Argument #%d: Scalar (1 element) expected.\n");
383 error(msprintf(msg, fname, iarg));
185 end 384 end
186 end
187 end
188 385
189 // check for "fill" argument 386 elseif v=="datatips"
190 fill = %F; 387 if typeof(val)=="implicitlist"
191 if size(argins) >= nextArgin then 388 val = horner(val, length(X))
192 if type(argins(nextArgin)) == 10 then 389 elseif type(val)<>1 | ~isreal(val) | ..
193 if argins(nextArgin) == "fill" then 390 or(val<1|val>length(X)) | or(val <> int(val))
194 fill = %T; 391 msg = _("%s: Argument #%d: Integers in %s expected.\n")
195 nextArgin = nextArgin + 1; 392 tmp = msprintf("[1,%d]",length(X));
393 error(msprintf(msg, fname, iarg, tmp))
196 end 394 end
395 // Indices of points for which a datatip must be created
396 datatips = val;
197 end 397 end
398 varargin(1) = null();
399 iarg = iarg + 1;
198 end 400 end
199 401 if mFGcolors==[] then
200 // check for marker argument 402 if mcolors <> [] then
201 markStyle = 9; // default circle 403 mFGcolors = mcolors
202 if size(argins) >= nextArgin then 404 else
203 if type(argins(nextArgin)) == 10 then 405 mFGcolors = color("blue");
204 ms = getMarkStyle(argins(nextArgin));
205 if ms >= 0 & ms <= 14 then
206 markStyle = ms;
207 nextArgin = nextArgin + 1;
208 end
209 end 406 end
210 end 407 end
211 408 if mBGcolors==[] then
212 // check for property-value pairs 409 if mcolors <> [] & fill
213 markFg = -1; 410 mBGcolors = mcolors
214 markBg = -1;
215 thickness = 1.0; // default
216 while size(argins) >= nextArgin do
217 if size(argins) == nextArgin then
218 warning("Incorrect number of inputs for property-value pairs.");
219 scanFailed = %T;
220 return;
221 else 411 else
222 select argins(nextArgin) 412 if ~fill
223 case "marker" 413 mBGcolors = 0 // Transparent
224 markStyle = getMarkStyle(argins(nextArgin+1)); 414 elseif mcolors <> []
225 if markStyle == -1 then 415 mBGcolors = mcolors
226 warning(strcat([argins(nextArgin+1) " is not a valid value for property marker."]));
227 scanFailed = %T;
228 return;
229 end
230 case "markerStyle"
231 markStyle = getMarkStyle(argin(nextArgin+1));
232 if markStyle == -1 then
233 warning(strcat([argins(nextArgin+1) " is not a valid value for property markerStyle."]));
234 scanFailed = %T;
235 return;
236 end
237 case "markerEdgeColor"
238 markFg = colorIndex(argins(nextArgin+1));
239 if markFg == -1 then
240 warning(strcat([argins(nextArgin+1) " is not a valid value for property markerEdgeColor."]));
241 scanFailed = %T;
242 return;
243 end;
244 case "markerForeground"
245 markFg = colorIndex(argins(nextArgin+1));
246 if markFg == -1 then
247 warning(strcat([argins(nextArgin+1) " is not a valid value for property markerForeground."]));
248 scanFailed = %T;
249 return;
250 end;
251 case "markerFaceColor"
252 fill = %T;
253 markBg = colorIndex(argins(nextArgin+1));
254 if markBg == -1 then
255 warning(strcat([argins(nextArgin+1) " is not a valid value for property markerFaceColor."]));
256 scanFailed = %T;
257 return;
258 end;
259 case "markerBackground"
260 fill = %T;
261 markBg = colorIndex(argins(nextArgin+1));
262 if markBg == -1 then
263 warning(strcat([argins(nextArgin+1) " is not a valid value for property markerBackground."]));
264 scanFailed = %T;
265 return;
266 end;
267 case "linewidth"
268 if type(argins(nextArgin+1)) == 1 then
269 thickness = argins(nextArgin+1);
270 else
271 warning(strcat([argins(nextArgin+1) " is not a valid value for property linewidth."]));
272 scanFailed = %T;
273 return;
274 end
275 case "thickness"
276 if type(argins(nextArgin+1)) == 1 then
277 thickness = argins(nextArgin+1);
278 else
279 warning(strcat([argins(nextArgin+1) " is not a valid value for property thickness."]));
280 scanFailed = %T;
281 return;
282 end
283 else 416 else
284 warning(strcat(["There is no " argins(nextArgin) " property on the Scatter class."])); 417 mBGcolors = color("blue")
285 scanFailed = %T;
286 return;
287 end 418 end
288 end 419 end
289 nextArgin = nextArgin + 2;
290 end 420 end
291 421 if mcolors == [] then
292endfunction 422 mcolors = color("blue"); // Default markers color
293
294function colorInd = colorIndex(colorSpec)
295 colorInd = -1;
296 if type(colorSpec) == 10 & size(colorSpec) == [1 1] then
297 colorRGB = name2rgb(colorSpec);
298 if ~isempty(colorRGB) then
299 colorInd = addcolor(colorRGB/255);
300 return;
301 end
302 elseif type(colorSpec) == 1 & (size(colorSpec) == [1 3] | size(colorSpec) == [3 1]) then
303 colorInd = addcolor(colorSpec);
304 return;
305 end 423 end
306 warning("Specified string is an invalid color value.");
307endfunction
308 424
309function markStyle = getMarkStyle(name) 425 // Option "smallOnTop"
310 if type(name) ~= 10 then 426 // -------------------
311 markStyle = -1; 427 if smallOnTop & length(msizes) > 1 then
312 else 428 [msizes, k] = gsort(msizes,"g");
313 select name 429 X = X(k);
314 case "." 430 Y = Y(k);
315 markStyle = 0; 431 if Z <> []
316 case "+" 432 Z = Z(k);
317 markStyle = 1; 433 end
318 case "x" 434 if length(thickness) > 1
319 markStyle = 2; 435 thickness = thickness(k);
320 case "circle plus" 436 end
321 markStyle = 3; 437 if length(markers) > 1
322 case "filled diamond" 438 markers = markers(k);
323 markStyle = 4; 439 end
324 case "d" 440 if length(mFGcolors) > 1
325 markStyle = 5; 441 mFGcolors = mFGcolors(k);
326 case "diamond" 442 end
327 markStyle = 5; 443 if length(mBGcolors) > 1
328 case "^" 444 mBGcolors = mBGcolors(k);
329 markStyle = 6; 445 end
330 case "v" 446 if length(datatips) > 1
331 markStyle = 7; 447 [?,kk] = gsort(k,"g","i");
332 case "diamond plus" 448 datatips = kk(datatips);
333 markStyle = 8;
334 case "o"
335 markStyle = 9;
336 case "*"
337 markStyle = 10;
338 case "s"
339 markStyle = 11;
340 case "square"
341 markStyle = 11;
342 case ">"
343 markStyle = 12;
344 case "<"
345 markStyle = 13;
346 case "p"
347 markStyle = 14;
348 case "pentagram"
349 markStyle = 14;
350 else
351 markStyle = -1;
352 end 449 end
353 end 450 end
354endfunction
355 451
356function colorIndex = scatterLinearColorMap(colorValue) 452 // ========
357 cMin = min(colorValue); 453 // PLOTTING
358 cMax = max(colorValue); 454 // ========
359 cmap = get(gcf(),"color_map"); 455 f = gcf();
360 numColors = size(cmap,1); 456 old_drawing_mode = f.immediate_drawing;
361 if (cMax-cMin > %eps) then 457 f.immediate_drawing = "off";
362 colorIndex = (numColors-1)*(colorValue - cMin)/(cMax - cMin) + 1; 458
459 if isempty(Z) then
460 plot(axesHandle, X,Y);
461 currentEntity = gce();
462 polyLine = currentEntity.children;
363 else 463 else
364 colorIndex = 1; // default color index 464 set("current_axes", axesHandle);
465 param3d(X,Y,Z);
466 polyLine = gce();
365 end 467 end
366endfunction
367
368function scatterSetPolyline(polyLine,S,C,thickness,markStyle,markFg,markBg,fill)
369
370 // set mark mode
371 polyLine.line_mode = "off";
372 polyLine.mark_mode = "on";
373
374 // set thickness
375 polyLine.thickness = thickness;
376
377 // set mark style
378 polyLine.mark_style = markStyle;
379 468
380 // set mark size 469 if polyLine.Type <> "Polyline" then
381 polyLine.mark_size_unit = "point"; 470 msg = _("%s: Argument #%d: Wrong type of graphic handle: ''%s'' expected.\n");
382 if isempty(S) then 471 warning(msprintf(msg, fname, -1, "Polyline"));
383 polyLine.mark_size = 7;
384 else 472 else
385 if size(S) == [1 1] | size(S) == [1 n] 473 polyLine.line_mode = "off";
386 polyLine.mark_size = ceil(sqrt(4*S/%pi)); 474 polyLine.mark_mode = "on";
387 else 475 polyLine.thickness = matrix(thickness, -1, 1);
388 warning("S must be a scalar or a vector of the same length as X."); 476 polyLine.mark_style = matrix(markers, -1, 1);
389 return; 477 polyLine.mark_size_unit = "point";
390 end 478 polyLine.mark_foreground = matrix(mFGcolors, 1, -1);
391 end 479 polyLine.mark_background = matrix(mBGcolors, 1, -1);
480 polyLine.mark_size = matrix(ceil(2*sqrt(msizes/%pi)),1,-1);
392 481
393 // set mark foreground and background color 482 if datatips <> []
394 if isempty(C) then 483 polyLine.datatip_display_mode = "mouseover";
395 if markFg == -1 then 484 dispSize = length(msizes) > 1
396 markFg = addcolor(name2rgb("blue")/255); // default 485 for i = matrix(datatips,1,-1)
397 end 486 kdat = datatipCreate(polyLine, i);
398 polyLine.mark_foreground = markFg; 487 if dispSize
399 if markBg == -1 then 488 kdat.user_data = msizes(i)
400 markBg = markFg; 489 kdat.text = [msprintf("size: %d",msizes(i)) ;
401 end 490 kdat.text ];
402 if fill == %T then
403 polyLine.mark_background = markBg;
404 else
405 polyLine.mark_background = 0; // transparent
406 end
407 else
408 if size(C) == [1 1] then
409 polyLine.mark_foreground = C;
410 if fill == %T then
411 polyLine.mark_background = C;
412 else
413 if markBg == -1 then
414 polyLine.mark_background = 0; // transparent
415 else
416 polyLine.mark_background = markBg;
417 end
418 end
419 else
420 if fill == %T then
421 if markFg == -1 then
422 polyLine.mark_foreground = C; // transparent
423 else
424 polyLine.mark_foreground = markFg;
425 end
426 polyLine.mark_background = C;
427 else
428 polyLine.mark_foreground = C;
429 if markBg == -1 then
430 polyLine.mark_background = 0; // transparent
431 else
432 polyLine.mark_background = markBg;
433 end 491 end
434 end 492 end
493 polyLine.datatips.mark_size = 1;
494 // polyLine.datatips.mark_mode = "off";
495 end
496 if ~isempty(Z) then
497 isoview off
498 set(gca(),"grid",[1 1 1]);
435 end 499 end
436 end 500 end
437 501
502 f.immediate_drawing = old_drawing_mode;
503
504 if lhs > 0 then
505 varargout = list(polyLine)
506 end
438endfunction 507endfunction
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_15481.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_15481.tst
new file mode 100644
index 0000000..6162aa0
--- /dev/null
+++ b/scilab/modules/graphics/tests/nonreg_tests/bug_15481.tst
@@ -0,0 +1,26 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2018 - Samuel GOUGEON
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- TEST WITH GRAPHIC -->
9// <-- NO CHECK REF -->
10
11// <-- Non-regression test for bug 15481 -->
12//
13// <-- Bugzilla URL -->
14// http://bugzilla.scilab.org/15481
15//
16// <-- Short Description -->
17// scatter() and scatter3d() failed for only one point
18
19clf reset
20assert_checkequal(execstr("scatter(1,2);", "errcatch"), 0);
21assert_checkequal(execstr("scatter(1,2,100);", "errcatch"), 0);
22assert_checkequal(execstr("scatter(1,2,100, ""orange"");", "errcatch"), 0);
23
24assert_checkequal(execstr("scatter3d(1,2,3);", "errcatch"), 0);
25assert_checkequal(execstr("scatter3d(1,2,3,100);", "errcatch"), 0);
26assert_checkequal(execstr("scatter3d(1,2,3,100,""orange"");", "errcatch"), 0);
diff --git a/scilab/modules/graphics/tests/unit_tests/scatter.dia.ref b/scilab/modules/graphics/tests/unit_tests/scatter.dia.ref
deleted file mode 100644
index ad07c80..0000000
--- a/scilab/modules/graphics/tests/unit_tests/scatter.dia.ref
+++ /dev/null
@@ -1,222 +0,0 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) Scilab Enterprises - 2015-2010 - Juergen Koch <juergen.koch@hs-esslingen.de>
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- TEST WITH GRAPHIC -->
8//
9// test data
10rand("seed",0);
11x = linspace(0,2,200);
12y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
13s = linspace(1,30,length(x));
14//
15// Test #1 Create 2D scatter plot
16h = scf();
17p = scatter(x,y);
18assert_checkequal(p.line_mode,"off");
19assert_checkequal(p.fill_mode,"off");
20assert_checkequal(p.thickness,1);
21assert_checkequal(p.mark_mode,"on");
22assert_checkequal(p.mark_style,9);
23assert_checkequal(p.mark_size_unit,"point");
24assert_checkequal(p.mark_size,7);
25assert_checkequal(p.mark_foreground,2);
26assert_checkequal(p.mark_background,0);
27close(h);
28//
29// Test #2 Vary marker size
30h = scf();
31p = scatter(x,y,s);
32assert_checkequal(p.line_mode,"off");
33assert_checkequal(p.fill_mode,"off");
34assert_checkequal(p.thickness,1);
35assert_checkequal(p.mark_mode,"on");
36assert_checkequal(p.mark_style,9);
37assert_checkequal(p.mark_size_unit,"point");
38assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
39assert_checkequal(p.mark_foreground,2);
40assert_checkequal(p.mark_background,0);
41close(h);
42//
43// Test #3 Vary marker size and color
44h = scf();
45set(gcf(),"color_map",coolcolormap(64))
46p = scatter(x,y,s,x);
47assert_checkequal(p.line_mode,"off");
48assert_checkequal(p.fill_mode,"off");
49assert_checkequal(p.thickness,1);
50assert_checkequal(p.mark_mode,"on");
51assert_checkequal(p.mark_style,9);
52assert_checkequal(p.mark_size_unit,"point");
53assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
54assert_checkequal(p.mark_foreground,floor((64-1)*(x-min(x))/(max(x)-min(x))+1));
55assert_checkequal(p.mark_background,0);
56close(h);
57//
58// Test #4 Fill the markers
59h = scf();
60p = scatter(x,y,s,y,"fill");
61assert_checkequal(p.line_mode,"off");
62assert_checkequal(p.fill_mode,"off");
63assert_checkequal(p.thickness,1);
64assert_checkequal(p.mark_mode,"on");
65assert_checkequal(p.mark_style,9);
66assert_checkequal(p.mark_size_unit,"point");
67assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
68assert_checkequal(p.mark_foreground,floor((32-1)*(y-min(y))/(max(y)-min(y))+1));
69assert_checkequal(p.mark_background,floor((32-1)*(y-min(y))/(max(y)-min(y))+1));
70close(h);
71//
72// Test #5 Specify subplot for scatter plot
73h = scf();
74subplot(2,1,1);
75p1 = scatter(gca(),x,y);
76assert_checkequal(p1.line_mode,"off");
77assert_checkequal(p1.fill_mode,"off");
78assert_checkequal(p1.thickness,1);
79assert_checkequal(p1.mark_mode,"on");
80assert_checkequal(p1.mark_style,9);
81assert_checkequal(p1.mark_size_unit,"point");
82assert_checkequal(p1.mark_size,7);
83assert_checkequal(p1.mark_foreground,2);
84assert_checkequal(p1.mark_background,0);
85subplot(2,1,2);
86p2 = scatter(gca(),x,y,"fill","s");
87assert_checkequal(p2.line_mode,"off");
88assert_checkequal(p2.fill_mode,"off");
89assert_checkequal(p2.thickness,1);
90assert_checkequal(p2.mark_mode,"on");
91assert_checkequal(p2.mark_style,11);
92assert_checkequal(p2.mark_size_unit,"point");
93assert_checkequal(p2.mark_size,7);
94assert_checkequal(p2.mark_foreground,2);
95assert_checkequal(p2.mark_background,2);
96close(h);
97//
98// test data
99rand("seed",0);
100x = rand(1,200);
101y = rand(1,200);
102//
103// Test #6 Specify marker symbol
104h = scf();
105p = scatter(x,y,"d");
106assert_checkequal(p.line_mode,"off");
107assert_checkequal(p.fill_mode,"off");
108assert_checkequal(p.thickness,1);
109assert_checkequal(p.mark_mode,"on");
110assert_checkequal(p.mark_style,5);
111assert_checkequal(p.mark_size_unit,"point");
112assert_checkequal(p.mark_size,7);
113assert_checkequal(p.mark_foreground,2);
114assert_checkequal(p.mark_background,0);
115close(h);
116//
117// Test #7 Change marker color and line width
118h = scf();
119p = scatter(x,y,"markerEdgeColor",[0 .4 .4],...
120 "markerFaceColor",[0 .8 .8],...
121 "linewidth",1.5);
122assert_checkequal(p.line_mode,"off");
123assert_checkequal(p.fill_mode,"off");
124assert_checkequal(p.thickness,1.5);
125assert_checkequal(p.mark_mode,"on");
126assert_checkequal(p.mark_style,9);
127assert_checkequal(p.mark_size_unit,"point");
128assert_checkequal(p.mark_size,7);
129assert_checkequal(p.mark_foreground,color(0,.4*255,.4*255));
130assert_checkequal(p.mark_background,color(0,.8*255,.8*255));
131close(h);
132//
133// Test data
134t = linspace(0,25,200);
135x = t.*cos(t);
136y = t.*sin(t);
137//
138// Test #8 Modify scatter plot after creation
139h = scf();
140p = scatter(x,y,t);
141p.thickness = 0.5;
142p.mark_foreground = color("darkblue");
143p.mark_background = color("darkcyan");
144assert_checkequal(p.line_mode,"off");
145assert_checkequal(p.fill_mode,"off");
146assert_checkequal(p.thickness,0.5);
147assert_checkequal(p.mark_mode,"on");
148assert_checkequal(p.mark_style,9);
149assert_checkequal(p.mark_size_unit,"point");
150assert_checkequal(p.mark_size,ceil(sqrt(4*t/%pi)));
151assert_checkequal(p.mark_foreground,color("darkblue"));
152assert_checkequal(p.mark_background,color("darkcyan"));
153close(h);
154//
155// Test #9 Testing graphics handle
156h = scf();
157p = scatter(gca(),x,y,t);
158assert_checkequal(p.line_mode,"off");
159assert_checkequal(p.fill_mode,"off");
160assert_checkequal(p.thickness,1);
161assert_checkequal(p.mark_mode,"on");
162assert_checkequal(p.mark_style,9);
163assert_checkequal(p.mark_size_unit,"point");
164assert_checkequal(p.mark_size,ceil(sqrt(4*t/%pi)));
165assert_checkequal(p.mark_foreground,2);
166assert_checkequal(p.mark_background,0);
167close(h);
168//
169// Test data
170x = 0.1:0.2:0.9;
171//
172// Test #10 Testing single color string specification
173h = scf();
174p = scatter(x,x,[],"red");
175assert_checkequal(p.line_mode,"off");
176assert_checkequal(p.fill_mode,"off");
177assert_checkequal(p.thickness,1);
178assert_checkequal(p.mark_mode,"on");
179assert_checkequal(p.mark_style,9);
180assert_checkequal(p.mark_size_unit,"point");
181assert_checkequal(p.mark_size,7);
182assert_checkequal(p.mark_foreground,color("red"));
183assert_checkequal(p.mark_background,0);
184close(h);
185//
186// Test #11 Testing color vector of strings specification
187h = scf();
188p = scatter(x,x,[],["red" "green" "blue" "grey" "black"]);
189assert_checkequal(p.line_mode,"off");
190assert_checkequal(p.fill_mode,"off");
191assert_checkequal(p.thickness,1);
192assert_checkequal(p.mark_mode,"on");
193assert_checkequal(p.mark_style,9);
194assert_checkequal(p.mark_size_unit,"point");
195assert_checkequal(p.mark_size,7);
196assert_checkequal(p.mark_foreground,[color("red") color("green") color("blue") color("grey") color("black")]);
197assert_checkequal(p.mark_background,0);
198close(h);
199//
200// Test #12 Testing color RGB matrix specification
201h = scf();
202RGB = [255 0 0
203 0 255 0
204 0 0 255
205 128 128 128
206 0 0 0];
207p = scatter(x,x,[],RGB/255);
208assert_checkequal(p.line_mode,"off");
209assert_checkequal(p.fill_mode,"off");
210assert_checkequal(p.thickness,1);
211assert_checkequal(p.mark_mode,"on");
212assert_checkequal(p.mark_style,9);
213assert_checkequal(p.mark_size_unit,"point");
214assert_checkequal(p.mark_size,7);
215assert_checkequal(p.mark_foreground,...
216[color(RGB(1,1),RGB(1,2),RGB(1,3))...
217 color(RGB(2,1),RGB(2,2),RGB(2,3))...
218 color(RGB(3,1),RGB(3,2),RGB(3,3))...
219 color(RGB(4,1),RGB(4,2),RGB(4,3))...
220 color(RGB(5,1),RGB(5,2),RGB(5,3))]);
221assert_checkequal(p.mark_background,0);
222close(h);
diff --git a/scilab/modules/graphics/tests/unit_tests/scatter.tst b/scilab/modules/graphics/tests/unit_tests/scatter.tst
index e6565dd..06499b7 100644
--- a/scilab/modules/graphics/tests/unit_tests/scatter.tst
+++ b/scilab/modules/graphics/tests/unit_tests/scatter.tst
@@ -1,12 +1,14 @@
1// ============================================================================= 1// ===================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) Scilab Enterprises - 2015-2010 - Juergen Koch <juergen.koch@hs-esslingen.de> 3// Copyright (C) 2015-2010 - Scilab Enterprises - Juergen Koch <juergen.koch@hs-esslingen.de>
4// Copyright (C) 2018-2020 - Samuel GOUGEON
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 7// ===================================================================
7 8
8// <-- TEST WITH GRAPHIC --> 9// <-- TEST WITH GRAPHIC -->
9 10// <-- NO CHECK REF -->
11// <-- ENGLISH IMPOSED -->
10// 12//
11// test data 13// test data
12rand("seed",0); 14rand("seed",0);
@@ -14,9 +16,10 @@ x = linspace(0,2,200);
14y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x)); 16y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
15s = linspace(1,30,length(x)); 17s = linspace(1,30,length(x));
16 18
19clf reset
20
17// 21//
18// Test #1 Create 2D scatter plot 22// Test #1 Create 2D scatter plot
19h = scf();
20p = scatter(x,y); 23p = scatter(x,y);
21assert_checkequal(p.line_mode,"off"); 24assert_checkequal(p.line_mode,"off");
22assert_checkequal(p.fill_mode,"off"); 25assert_checkequal(p.fill_mode,"off");
@@ -27,10 +30,9 @@ assert_checkequal(p.mark_size_unit,"point");
27assert_checkequal(p.mark_size,7); 30assert_checkequal(p.mark_size,7);
28assert_checkequal(p.mark_foreground,2); 31assert_checkequal(p.mark_foreground,2);
29assert_checkequal(p.mark_background,0); 32assert_checkequal(p.mark_background,0);
30close(h);
31// 33//
32// Test #2 Vary marker size 34// Test #2 Vary marker size
33h = scf(); 35clf
34p = scatter(x,y,s); 36p = scatter(x,y,s);
35assert_checkequal(p.line_mode,"off"); 37assert_checkequal(p.line_mode,"off");
36assert_checkequal(p.fill_mode,"off"); 38assert_checkequal(p.fill_mode,"off");
@@ -41,10 +43,9 @@ assert_checkequal(p.mark_size_unit,"point");
41assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); 43assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
42assert_checkequal(p.mark_foreground,2); 44assert_checkequal(p.mark_foreground,2);
43assert_checkequal(p.mark_background,0); 45assert_checkequal(p.mark_background,0);
44close(h);
45// 46//
46// Test #3 Vary marker size and color 47// Test #3 Vary marker size and color
47h = scf(); 48clf
48set(gcf(),"color_map",coolcolormap(64)) 49set(gcf(),"color_map",coolcolormap(64))
49p = scatter(x,y,s,x); 50p = scatter(x,y,s,x);
50assert_checkequal(p.line_mode,"off"); 51assert_checkequal(p.line_mode,"off");
@@ -54,12 +55,11 @@ assert_checkequal(p.mark_mode,"on");
54assert_checkequal(p.mark_style,9); 55assert_checkequal(p.mark_style,9);
55assert_checkequal(p.mark_size_unit,"point"); 56assert_checkequal(p.mark_size_unit,"point");
56assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); 57assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
57assert_checkequal(p.mark_foreground,floor((64-1)*(x-min(x))/(max(x)-min(x))+1)); 58assert_checkequal(p.mark_foreground, round((64-1)*(x-min(x))/(max(x)-min(x))+1));
58assert_checkequal(p.mark_background,0); 59assert_checkequal(p.mark_background, 0);
59close(h);
60// 60//
61// Test #4 Fill the markers 61// Test #4 Fill the markers
62h = scf(); 62clf reset
63p = scatter(x,y,s,y,"fill"); 63p = scatter(x,y,s,y,"fill");
64assert_checkequal(p.line_mode,"off"); 64assert_checkequal(p.line_mode,"off");
65assert_checkequal(p.fill_mode,"off"); 65assert_checkequal(p.fill_mode,"off");
@@ -68,12 +68,11 @@ assert_checkequal(p.mark_mode,"on");
68assert_checkequal(p.mark_style,9); 68assert_checkequal(p.mark_style,9);
69assert_checkequal(p.mark_size_unit,"point"); 69assert_checkequal(p.mark_size_unit,"point");
70assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); 70assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
71assert_checkequal(p.mark_foreground,floor((32-1)*(y-min(y))/(max(y)-min(y))+1)); 71assert_checkequal(p.mark_foreground, round((32-1)*(y-min(y))/(max(y)-min(y))+1));
72assert_checkequal(p.mark_background,floor((32-1)*(y-min(y))/(max(y)-min(y))+1)); 72assert_checkequal(p.mark_background, round((32-1)*(y-min(y))/(max(y)-min(y))+1));
73close(h);
74// 73//
75// Test #5 Specify subplot for scatter plot 74// Test #5 Specify subplot for scatter plot
76h = scf(); 75clf
77subplot(2,1,1); 76subplot(2,1,1);
78p1 = scatter(gca(),x,y); 77p1 = scatter(gca(),x,y);
79assert_checkequal(p1.line_mode,"off"); 78assert_checkequal(p1.line_mode,"off");
@@ -86,7 +85,7 @@ assert_checkequal(p1.mark_size,7);
86assert_checkequal(p1.mark_foreground,2); 85assert_checkequal(p1.mark_foreground,2);
87assert_checkequal(p1.mark_background,0); 86assert_checkequal(p1.mark_background,0);
88subplot(2,1,2); 87subplot(2,1,2);
89p2 = scatter(gca(),x,y,"fill","s"); 88p2 = scatter(gca(),x,y,"fill","s"); // msizes & mcolors are implicitly skipped !
90assert_checkequal(p2.line_mode,"off"); 89assert_checkequal(p2.line_mode,"off");
91assert_checkequal(p2.fill_mode,"off"); 90assert_checkequal(p2.fill_mode,"off");
92assert_checkequal(p2.thickness,1); 91assert_checkequal(p2.thickness,1);
@@ -96,7 +95,6 @@ assert_checkequal(p2.mark_size_unit,"point");
96assert_checkequal(p2.mark_size,7); 95assert_checkequal(p2.mark_size,7);
97assert_checkequal(p2.mark_foreground,2); 96assert_checkequal(p2.mark_foreground,2);
98assert_checkequal(p2.mark_background,2); 97assert_checkequal(p2.mark_background,2);
99close(h);
100 98
101// 99//
102// test data 100// test data
@@ -106,8 +104,8 @@ y = rand(1,200);
106 104
107// 105//
108// Test #6 Specify marker symbol 106// Test #6 Specify marker symbol
109h = scf(); 107clf
110p = scatter(x,y,"d"); 108p = scatter(x,y,"d"); // msizes, mcolors and "fill" are implicitly skipped !
111assert_checkequal(p.line_mode,"off"); 109assert_checkequal(p.line_mode,"off");
112assert_checkequal(p.fill_mode,"off"); 110assert_checkequal(p.fill_mode,"off");
113assert_checkequal(p.thickness,1); 111assert_checkequal(p.thickness,1);
@@ -117,10 +115,9 @@ assert_checkequal(p.mark_size_unit,"point");
117assert_checkequal(p.mark_size,7); 115assert_checkequal(p.mark_size,7);
118assert_checkequal(p.mark_foreground,2); 116assert_checkequal(p.mark_foreground,2);
119assert_checkequal(p.mark_background,0); 117assert_checkequal(p.mark_background,0);
120close(h);
121// 118//
122// Test #7 Change marker color and line width 119// Test #7 Change marker color and line width
123h = scf(); 120clf
124p = scatter(x,y,"markerEdgeColor",[0 .4 .4],... 121p = scatter(x,y,"markerEdgeColor",[0 .4 .4],...
125 "markerFaceColor",[0 .8 .8],... 122 "markerFaceColor",[0 .8 .8],...
126 "linewidth",1.5); 123 "linewidth",1.5);
@@ -133,7 +130,6 @@ assert_checkequal(p.mark_size_unit,"point");
133assert_checkequal(p.mark_size,7); 130assert_checkequal(p.mark_size,7);
134assert_checkequal(p.mark_foreground,color(0,.4*255,.4*255)); 131assert_checkequal(p.mark_foreground,color(0,.4*255,.4*255));
135assert_checkequal(p.mark_background,color(0,.8*255,.8*255)); 132assert_checkequal(p.mark_background,color(0,.8*255,.8*255));
136close(h);
137 133
138// 134//
139// Test data 135// Test data
@@ -143,7 +139,7 @@ y = t.*sin(t);
143 139
144// 140//
145// Test #8 Modify scatter plot after creation 141// Test #8 Modify scatter plot after creation
146h = scf(); 142clf
147p = scatter(x,y,t); 143p = scatter(x,y,t);
148p.thickness = 0.5; 144p.thickness = 0.5;
149p.mark_foreground = color("darkblue"); 145p.mark_foreground = color("darkblue");
@@ -157,10 +153,9 @@ assert_checkequal(p.mark_size_unit,"point");
157assert_checkequal(p.mark_size,ceil(sqrt(4*t/%pi))); 153assert_checkequal(p.mark_size,ceil(sqrt(4*t/%pi)));
158assert_checkequal(p.mark_foreground,color("darkblue")); 154assert_checkequal(p.mark_foreground,color("darkblue"));
159assert_checkequal(p.mark_background,color("darkcyan")); 155assert_checkequal(p.mark_background,color("darkcyan"));
160close(h);
161// 156//
162// Test #9 Testing graphics handle 157// Test #9 Testing graphics handle
163h = scf(); 158clf
164p = scatter(gca(),x,y,t); 159p = scatter(gca(),x,y,t);
165assert_checkequal(p.line_mode,"off"); 160assert_checkequal(p.line_mode,"off");
166assert_checkequal(p.fill_mode,"off"); 161assert_checkequal(p.fill_mode,"off");
@@ -171,7 +166,6 @@ assert_checkequal(p.mark_size_unit,"point");
171assert_checkequal(p.mark_size,ceil(sqrt(4*t/%pi))); 166assert_checkequal(p.mark_size,ceil(sqrt(4*t/%pi)));
172assert_checkequal(p.mark_foreground,2); 167assert_checkequal(p.mark_foreground,2);
173assert_checkequal(p.mark_background,0); 168assert_checkequal(p.mark_background,0);
174close(h);
175 169
176// 170//
177// Test data 171// Test data
@@ -179,7 +173,7 @@ x = 0.1:0.2:0.9;
179 173
180// 174//
181// Test #10 Testing single color string specification 175// Test #10 Testing single color string specification
182h = scf(); 176clf
183p = scatter(x,x,[],"red"); 177p = scatter(x,x,[],"red");
184assert_checkequal(p.line_mode,"off"); 178assert_checkequal(p.line_mode,"off");
185assert_checkequal(p.fill_mode,"off"); 179assert_checkequal(p.fill_mode,"off");
@@ -190,10 +184,9 @@ assert_checkequal(p.mark_size_unit,"point");
190assert_checkequal(p.mark_size,7); 184assert_checkequal(p.mark_size,7);
191assert_checkequal(p.mark_foreground,color("red")); 185assert_checkequal(p.mark_foreground,color("red"));
192assert_checkequal(p.mark_background,0); 186assert_checkequal(p.mark_background,0);
193close(h);
194// 187//
195// Test #11 Testing color vector of strings specification 188// Test #11 Testing color vector of strings specification
196h = scf(); 189clf
197p = scatter(x,x,[],["red" "green" "blue" "grey" "black"]); 190p = scatter(x,x,[],["red" "green" "blue" "grey" "black"]);
198assert_checkequal(p.line_mode,"off"); 191assert_checkequal(p.line_mode,"off");
199assert_checkequal(p.fill_mode,"off"); 192assert_checkequal(p.fill_mode,"off");
@@ -204,10 +197,9 @@ assert_checkequal(p.mark_size_unit,"point");
204assert_checkequal(p.mark_size,7); 197assert_checkequal(p.mark_size,7);
205assert_checkequal(p.mark_foreground,[color("red") color("green") color("blue") color("grey") color("black")]); 198assert_checkequal(p.mark_foreground,[color("red") color("green") color("blue") color("grey") color("black")]);
206assert_checkequal(p.mark_background,0); 199assert_checkequal(p.mark_background,0);
207close(h);
208// 200//
209// Test #12 Testing color RGB matrix specification 201// Test #12 Testing color RGB matrix specification
210h = scf(); 202clf
211RGB = [255 0 0 203RGB = [255 0 0
212 0 255 0 204 0 255 0
213 0 0 255 205 0 0 255
@@ -228,4 +220,88 @@ assert_checkequal(p.mark_foreground,...
228 color(RGB(4,1),RGB(4,2),RGB(4,3))... 220 color(RGB(4,1),RGB(4,2),RGB(4,3))...
229 color(RGB(5,1),RGB(5,2),RGB(5,3))]); 221 color(RGB(5,1),RGB(5,2),RGB(5,3))]);
230assert_checkequal(p.mark_background,0); 222assert_checkequal(p.mark_background,0);
231close(h); 223
224// ==============
225// Error messages
226// ==============
227msg = "scatter: Wrong number of input arguments: At least 2 expected.";
228assert_checkerror("scatter(1)", msg);
229msg = "scatter: Wrong number of input arguments: At least 3 expected.";
230assert_checkerror("scatter(gca(),1)", msg);
231msg = "scatter: Argument #1: Wrong type of graphic handle: ''Axes'' expected.";
232assert_checkerror("scatter(gcf(),1,2)", msg);
233msg = "scatter: Argument #1: Decimal number(s) expected.";
234assert_checkerror("scatter(int8(1),2)", msg);
235assert_checkerror("scatter(1+%i,2)", msg);
236msg = "scatter: Argument #2: Decimal number(s) expected.";
237assert_checkerror("scatter(1,int8(2))", msg);
238assert_checkerror("scatter(1,2-%i)", msg);
239assert_checkerror("scatter(1,%z)", msg);
240msg = "scatter: Arguments #1 and #2: Same numbers of elements expected.";
241assert_checkerror("scatter(1,[2 3])", msg);
242
243msg = "scatter: Argument #3: Decimal number(s) expected.";
244assert_checkerror("scatter(1,2,%i)", msg);
245msg = "scatter: Argument #3: Wrong value. Please check allowed syntaxes and values.";
246assert_checkerror("scatter(1,2,""A"")", msg);
247msg = "scatter: Arguments #1 and #3: Same numbers of elements expected.";
248assert_checkerror("scatter(1,2,[1 2])", msg);
249msg = "scatter: Argument #4: Wrong size: one or 1 colors expected.";
250assert_checkerror("scatter(1,2,3,[1 2])", msg);
251assert_checkerror("scatter(1,2,3,[""cyan"" ""red""])", msg);
252
253msg = "scatter: Argument #4: Decimal number(s) expected.";
254assert_checkerror("scatter(1,2,3,%i)", msg);
255
256// ==========
257// Properties
258// ==========
259// Marks styles (case insensitive)
260prop = ["marker" "MarKeR" "markerstyle" "MARKSTYLE"];
261markersT = ["." "+" "x" "o" "o+" "circle plus" "d" "fd" "filled diamond" ..
262"d+" "diamond plus" "^" "v" ">" "<" "*" "*5" "p" "pentagram" "s" "square"];
263 // Markers Numerical codes styles (available)
264markersN = [ 0 1 2 9 3 3 5 4 4 ..
265 8 8 6 7 12 13 10 14 14 14 11 11];
266x = rand(1,20);
267y = rand(1,20);
268for p = prop
269 for v = markersT
270 assert_checkequal(execstr("clf, scatter(x,y,p,v);", "errcatch"), 0);
271 sleep(50)
272 end
273 for v = unique(markersN)
274 assert_checkequal(execstr("clf, scatter(x,y,p,v);", "errcatch"), 0);
275 sleep(50)
276 end
277end
278msg = "scatter: Argument #4: Wrong marker specification.";
279assert_checkerror("scatter(1,2,""marker"",""ab"")", msg);
280assert_checkerror("scatter(1,2,""marker"", 20)", msg);
281msg = "scatter: Argument #4: Scalar (1 element) expected.";
282assert_checkerror("scatter(1,2,""marker"",[1 2])", msg);
283msg = "scatter: Argument #5: Unknown property name ''A''.";
284assert_checkerror("scatter(1,2,10,4,""A"")", msg);
285
286msg = "scatter: Argument #4: Scalar (1 element) expected.";
287assert_checkerror("scatter(1,2,""linewidth"",[1 2])", msg);
288assert_checkerror("scatter(1,2,""thickness"",[1 2])", msg);
289msg = "scatter: Argument #4: Non-negative integers expected.";
290assert_checkerror("scatter(1,2,""linewidth"", -1)", msg);
291assert_checkerror("scatter(1,2,""thickness"", -1)", msg);
292assert_checkerror("scatter(1,2,""linewidth"", %i)", msg);
293assert_checkerror("scatter(1,2,""thickness"", %i)", msg);
294assert_checkerror("scatter(1,2,""linewidth"", %z)", msg);
295assert_checkerror("scatter(1,2,""thickness"", %z)", msg);
296
297prop = ["markeredgecolor" "markerforeground" ..
298 "markerfacecolor" "markerbackground"];
299for p = prop
300 assert_checkequal(execstr("clf, scatter(1,2, p,""orange"")", "errcatch"),0);
301 assert_checkequal(execstr("clf, scatter(1,2, p,""#00FF00"")", "errcatch"),0);
302 assert_checkequal(execstr("clf, scatter(1,2, p, color(""red""))", "errcatch"),0);
303end
304msg = "scatter: Argument #3: Value missing for the given property.";
305assert_checkerror("scatter(1,2,""marker"")", msg);
306msg = "scatter: Argument #3: Wrong value. Please check allowed syntaxes and values.";
307assert_checkerror("scatter(1,2,""orange"",""AbCd"",[1 2])", msg);
diff --git a/scilab/modules/graphics/tests/unit_tests/scatter3d.tst b/scilab/modules/graphics/tests/unit_tests/scatter3d.tst
index ebc5e87..26e4050 100644
--- a/scilab/modules/graphics/tests/unit_tests/scatter3d.tst
+++ b/scilab/modules/graphics/tests/unit_tests/scatter3d.tst
@@ -1,13 +1,14 @@
1// ============================================================================= 1// ===================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) Scilab Enterprises - 2015-2010 - Juergen Koch <juergen.koch@hs-esslingen.de> 3// Copyright (C) 2010-2015 - Scilab Enterprises - Juergen Koch <juergen.koch@hs-esslingen.de>
4// Copyright (C) 2018-2020 - Samuel GOUGEON
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 7// ===================================================================
7 8
8// <-- TEST WITH GRAPHIC --> 9// <-- TEST WITH GRAPHIC -->
9// <-- NO CHECK REF --> 10// <-- NO CHECK REF -->
10 11// <-- ENGLISH IMPOSED -->
11// 12//
12// Test data 13// Test data
13t = 1:200; 14t = 1:200;
@@ -18,7 +19,7 @@ s = linspace(50,1,length(t));
18 19
19// 20//
20// Test #1 Create 3D scatter plot 21// Test #1 Create 3D scatter plot
21h = scf(); 22clf reset
22p = scatter3d(x,y,z); 23p = scatter3d(x,y,z);
23assert_checkequal(p.line_mode,"off"); 24assert_checkequal(p.line_mode,"off");
24assert_checkequal(p.fill_mode,"off"); 25assert_checkequal(p.fill_mode,"off");
@@ -29,11 +30,9 @@ assert_checkequal(p.mark_size_unit,"point");
29assert_checkequal(p.mark_size,7); 30assert_checkequal(p.mark_size,7);
30assert_checkequal(p.mark_foreground,2); 31assert_checkequal(p.mark_foreground,2);
31assert_checkequal(p.mark_background,0); 32assert_checkequal(p.mark_background,0);
32set(gca(),"rotation_angles",[60,45]);
33close(h);
34// 33//
35// Test #2 Vary marker size 34// Test #2 Vary marker size
36h = scf(); 35clf reset
37p = scatter3d(x,y,z,s); 36p = scatter3d(x,y,z,s);
38assert_checkequal(p.line_mode,"off"); 37assert_checkequal(p.line_mode,"off");
39assert_checkequal(p.fill_mode,"off"); 38assert_checkequal(p.fill_mode,"off");
@@ -44,11 +43,9 @@ assert_checkequal(p.mark_size_unit,"point");
44assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); 43assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
45assert_checkequal(p.mark_foreground,2); 44assert_checkequal(p.mark_foreground,2);
46assert_checkequal(p.mark_background,0); 45assert_checkequal(p.mark_background,0);
47set(gca(),"rotation_angles",[60,45]);
48close(h);
49// 46//
50// Test #3 Vary marker size and color 47// Test #3 Vary marker size and color
51h = scf(); 48clf reset
52set(gcf(),"color_map",coolcolormap(64)); 49set(gcf(),"color_map",coolcolormap(64));
53p = scatter3d(x,y,z,s,t); 50p = scatter3d(x,y,z,s,t);
54assert_checkequal(p.line_mode,"off"); 51assert_checkequal(p.line_mode,"off");
@@ -57,11 +54,10 @@ assert_checkequal(p.thickness,1);
57assert_checkequal(p.mark_mode,"on"); 54assert_checkequal(p.mark_mode,"on");
58assert_checkequal(p.mark_style,9); 55assert_checkequal(p.mark_style,9);
59assert_checkequal(p.mark_size_unit,"point"); 56assert_checkequal(p.mark_size_unit,"point");
60assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); 57assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); //
61assert_checkequal(p.mark_foreground,floor((64-1)*(t-min(t))/(max(t)-min(t))+1)); 58assert_checkequal(p.mark_foreground, round((64-1)*(t-min(t))/(max(t)-min(t))+1)); //
62assert_checkequal(p.mark_background,0); 59assert_checkequal(p.mark_background,0);
63set(gca(),"rotation_angles",[60,45]); 60set(gca(),"rotation_angles",[60,45]);
64close(h);
65 61
66// 62//
67// Test data 63// Test data
@@ -71,7 +67,7 @@ y = z.*sin(z);
71 67
72// 68//
73// Test #4 Fill the markers 69// Test #4 Fill the markers
74h = scf(); 70clf reset
75p = scatter3d(x,y,z,"fill"); 71p = scatter3d(x,y,z,"fill");
76assert_checkequal(p.line_mode,"off"); 72assert_checkequal(p.line_mode,"off");
77assert_checkequal(p.fill_mode,"off"); 73assert_checkequal(p.fill_mode,"off");
@@ -82,11 +78,10 @@ assert_checkequal(p.mark_size_unit,"point");
82assert_checkequal(p.mark_size,7); 78assert_checkequal(p.mark_size,7);
83assert_checkequal(p.mark_foreground,2); 79assert_checkequal(p.mark_foreground,2);
84assert_checkequal(p.mark_background,2); 80assert_checkequal(p.mark_background,2);
85set(gca(),"rotation_angles",[60,45]); 81
86close(h);
87// 82//
88// Test #5 Specify marker symbol 83// Test #5 Specify marker symbol
89h = scf(); 84clf reset
90p = scatter3d(x,y,z,"*"); 85p = scatter3d(x,y,z,"*");
91assert_checkequal(p.line_mode,"off"); 86assert_checkequal(p.line_mode,"off");
92assert_checkequal(p.fill_mode,"off"); 87assert_checkequal(p.fill_mode,"off");
@@ -97,11 +92,10 @@ assert_checkequal(p.mark_size_unit,"point");
97assert_checkequal(p.mark_size,7); 92assert_checkequal(p.mark_size,7);
98assert_checkequal(p.mark_foreground,2); 93assert_checkequal(p.mark_foreground,2);
99assert_checkequal(p.mark_background,0); 94assert_checkequal(p.mark_background,0);
100set(gca(),"rotation_angles",[60,45]); 95
101close(h);
102// 96//
103// Test #6 Change marker edge and face color 97// Test #6 Change marker edge and face color
104h = scf(); 98clf reset
105p = scatter3d(x,y,z,... 99p = scatter3d(x,y,z,...
106 "markerEdgeColor","black",... 100 "markerEdgeColor","black",...
107 "markerFaceColor",[0 .8 .8]); 101 "markerFaceColor",[0 .8 .8]);
@@ -114,11 +108,10 @@ assert_checkequal(p.mark_size_unit,"point");
114assert_checkequal(p.mark_size,7); 108assert_checkequal(p.mark_size,7);
115assert_checkequal(p.mark_foreground,color("black")); 109assert_checkequal(p.mark_foreground,color("black"));
116assert_checkequal(p.mark_background,color(0,.8*255,.8*255)); 110assert_checkequal(p.mark_background,color(0,.8*255,.8*255));
117set(gca(),"rotation_angles",[60,45]); 111
118close(h);
119// 112//
120// Test #7 Specify subplot for scatter plot 113// Test #7 Specify subplot for scatter plot
121h = scf(); 114clf reset
122[x,y] = meshgrid(linspace(-2,2,20)); 115[x,y] = meshgrid(linspace(-2,2,20));
123z = exp(-x.^2-y.^2); 116z = exp(-x.^2-y.^2);
124subplot(2,1,1); 117subplot(2,1,1);
@@ -132,7 +125,7 @@ assert_checkequal(p1.mark_size_unit,"point");
132assert_checkequal(p1.mark_size,7); 125assert_checkequal(p1.mark_size,7);
133assert_checkequal(p1.mark_foreground,2); 126assert_checkequal(p1.mark_foreground,2);
134assert_checkequal(p1.mark_background,0); 127assert_checkequal(p1.mark_background,0);
135set(gca(),"rotation_angles",[60,45]); 128
136subplot(2,1,2); 129subplot(2,1,2);
137p2 = scatter3d(gca(),x(:),y(:),z(:),"markerFaceColor",[0 .8 .8]); 130p2 = scatter3d(gca(),x(:),y(:),z(:),"markerFaceColor",[0 .8 .8]);
138assert_checkequal(p2.line_mode,"off"); 131assert_checkequal(p2.line_mode,"off");
@@ -144,8 +137,6 @@ assert_checkequal(p2.mark_size_unit,"point");
144assert_checkequal(p2.mark_size,7); 137assert_checkequal(p2.mark_size,7);
145assert_checkequal(p2.mark_foreground,2); 138assert_checkequal(p2.mark_foreground,2);
146assert_checkequal(p2.mark_background,color(0,.8*255,.8*255)); 139assert_checkequal(p2.mark_background,color(0,.8*255,.8*255));
147set(gca(),"rotation_angles",[60,45]);
148close(h);
149 140
150// 141//
151// Test data 142// Test data
@@ -157,7 +148,7 @@ s = linspace(50,1,length(t));
157 148
158// 149//
159// Test #8 Modify scatter plot after creation 150// Test #8 Modify scatter plot after creation
160h = scf(); 151clf reset
161p = scatter3d(x,y,z,s); 152p = scatter3d(x,y,z,s);
162p.mark_foreground = addcolor([0.5 0 0]); 153p.mark_foreground = addcolor([0.5 0 0]);
163p.mark_background = addcolor([0.5 0.5 0]); 154p.mark_background = addcolor([0.5 0.5 0]);
@@ -170,5 +161,85 @@ assert_checkequal(p.mark_size_unit,"point");
170assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi))); 161assert_checkequal(p.mark_size,ceil(sqrt(4*s/%pi)));
171assert_checkequal(p.mark_foreground,color(0.5*255,0,0)); 162assert_checkequal(p.mark_foreground,color(0.5*255,0,0));
172assert_checkequal(p.mark_background,color(0.5*255,0.5*255,0)); 163assert_checkequal(p.mark_background,color(0.5*255,0.5*255,0));
173set(gca(),"rotation_angles",[60,45]); 164
174close(h); 165
166// ==============
167// Error messages
168// ==============
169msg = "scatter3d: Wrong number of input arguments: At least 3 expected.";
170assert_checkerror("scatter3d(1,2)", msg);
171msg = "scatter3d: Wrong number of input arguments: At least 4 expected.";
172assert_checkerror("scatter3d(gca(),1,2)", msg);
173msg = "scatter3d: Argument #1: Wrong type of graphic handle: ''Axes'' expected.";
174assert_checkerror("scatter3d(gcf(),1,2,3)", msg);
175msg = "scatter3d: Argument #1: Decimal number(s) expected.";
176assert_checkerror("scatter3d(int8(1),2,3)", msg);
177assert_checkerror("scatter3d(1+%i,2,3)", msg);
178msg = "scatter3d: Argument #2: Decimal number(s) expected.";
179assert_checkerror("scatter3d(1,int8(2),3)", msg);
180assert_checkerror("scatter3d(1,2-%i,3)", msg);
181msg = "scatter3d: Arguments #1 and #2: Same numbers of elements expected.";
182assert_checkerror("scatter3d(1,[2 3],3)", msg);
183msg = "scatter3d: Argument #3: Decimal number(s) expected.";
184assert_checkerror("scatter3d(1,2,int8(3))", msg);
185assert_checkerror("scatter3d(1,2,%i)", msg);
186assert_checkerror("scatter3d(1,2,%z)", msg);
187msg = "scatter3d: Arguments #1 and #3: Same numbers of elements expected.";
188assert_checkerror("scatter3d(1, 2, [2 3])", msg);
189
190msg = "scatter3d: Argument #4: Decimal number(s) expected.";
191assert_checkerror("scatter3d(1,2,3,%i)", msg);
192
193// ==========
194// Properties
195// ==========
196// Accepted / forbidden syntaxes or values
197// ---------------------------------------
198// Marks styles (case insensitive)
199prop = ["marker" "MarKeR" "markerstyle" "MARKSTYLE"];
200markersT = ["." "+" "x" "o" "o+" "circle plus" "d" "fd" "filled diamond" ..
201"d+" "diamond plus" "^" "v" ">" "<" "*" "*5" "p" "pentagram" "s" "square"];
202 // Markers Numerical codes styles (available)
203markersN = [ 0 1 2 9 3 3 5 4 4 ..
204 8 8 6 7 12 13 10 14 14 14 11 11];
205x = rand(1,20);
206y = rand(1,20);
207z = rand(1,20);
208for p = prop
209 for v = markersT
210 assert_checkequal(execstr("clf, scatter3d(x,y,z,p,v);", "errcatch"), 0);
211 sleep(50)
212 end
213 for v = unique(markersN)
214 assert_checkequal(execstr("clf, scatter3d(x,y,z,p,v);", "errcatch"), 0);
215 sleep(50)
216 end
217end
218msg = "scatter3d: Argument #5: Wrong marker specification.";
219assert_checkerror("scatter3d(1,2,3,""marker"",""ab"")", msg);
220assert_checkerror("scatter3d(1,2,3,""marker"", 20)", msg);
221msg = "scatter3d: Argument #5: Scalar (1 element) expected.";
222assert_checkerror("scatter3d(1,2,3,""marker"",[1 2])", msg);
223
224msg = "scatter3d: Argument #5: Scalar (1 element) expected.";
225assert_checkerror("scatter3d(1,2,3,""linewidth"",[1 2])", msg);
226assert_checkerror("scatter3d(1,2,3,""thickness"",[1 2])", msg);
227msg = "scatter3d: Argument #5: Non-negative integers expected.";
228assert_checkerror("scatter3d(1,2,3,""linewidth"", -1)", msg);
229assert_checkerror("scatter3d(1,2,3,""thickness"", -1)", msg);
230assert_checkerror("scatter3d(1,2,3,""linewidth"", %i)", msg);
231assert_checkerror("scatter3d(1,2,3,""thickness"", %i)", msg);
232assert_checkerror("scatter3d(1,2,3,""linewidth"", %z)", msg);
233assert_checkerror("scatter3d(1,2,3,""thickness"", %z)", msg);
234
235prop = ["markeredgecolor" "markerforeground" ..
236 "markerfacecolor" "markerbackground"];
237for p = prop
238 assert_checkequal(execstr("clf, scatter3d(1,2,3, p,""orange"")", "errcatch"),0);
239 assert_checkequal(execstr("clf, scatter3d(1,2,3, p,""#00FF00"")", "errcatch"),0);
240 assert_checkequal(execstr("clf, scatter3d(1,2,3, p, color(""red""))", "errcatch"),0);
241end
242msg = "scatter3d: Argument #4: Value missing for the given property.";
243assert_checkerror("scatter3d(1,2,3,""marker"")", msg);
244msg = "scatter3d: Argument #4: Wrong value. Please check allowed syntaxes and values.";
245assert_checkerror("scatter3d(1,2,3,""orange"",""AbCd"",[1 2])", msg);