1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
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.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
18 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
19 xml:lang="en" xml:id="scatter">
21 <refname>scatter</refname>
22 <refpurpose>2D scatter plot</refpurpose>
27 polyline = scatter(x, y, msizes, mcolors, "fill", marker, <marker_property, value>)
28 polyline = scatter(axes_handle,...)
32 <title>Arguments</title>
38 Columns or rows vectors of n real numbers specifying the abscissae and the
39 ordinates of the centers of markers.
47 Specifying the sizes of the markers. To plot each marker with equal sizes,
48 specify <varname>msizes</varname> as a scalar.
49 To plot each marker with a different size, specify <varname>msizes</varname>
50 as a vector with length equal to the length of <varname>x</varname> and
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.
62 Specifying the colors of the markers.
63 To plot each marker with the same color, specify <varname>mcolors</varname>
64 as a string representing a known color, see <link linkend="color_list">color_list</link>.
65 A color can also be specified by a vector of 3 RGB values between 0 and 1.
66 To plot each marker with a different color, specify <varname>mcolors</varname>
67 as a vector with length equal to the length of <varname>x</varname>.
68 The values of <varname>mcolors</varname> are linearly mapped to the colors
69 in the current colormap.
70 Colors can also by specified by a matrix of RGB values or a vector of
71 strings representing known colors.
72 A matrix of RGB values has 3 columns and the number of rows equals the
73 length of <varname>x</varname>.
74 The default color is "blue".
82 This string indicates that the markers are filled with some colors.
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
86 <varname>"markerBackgroundColor"</varname>.
94 Select the type of the marker. The same marker shape is used for all
95 specified points. The figure below shows the 15 different marker types.
100 <imagedata fileref="../../images/marks.svg"/>
105 Marker types are specified by strings, see the table below.
108 <informaltable border="1">
119 <literal>"."</literal>
125 <literal>"+"</literal>
131 <literal>"x"</literal>
137 <literal>"circle plus"</literal>
139 <td>Circle with plus</td>
143 <literal>"filled diamond"</literal>
145 <td>Filled diamond</td>
149 <literal>"d"</literal> or
150 <literal>"diamond"</literal>
156 <literal>"^"</literal>
158 <td>Upward-pointing triangle</td>
162 <literal>"v"</literal>
164 <td>Downward-pointing triangle</td>
168 <literal>"diamond plus"</literal>
170 <td>Diamond with plus</td>
174 <literal>"o"</literal>
176 <td>Circle (default)</td>
180 <literal>"*"</literal>
186 <literal>"s"</literal> or
187 <literal>"square"</literal>
193 <literal>">"</literal>
195 <td>Right-pointing triangle</td>
199 <literal>"<"</literal>
201 <td>Left-pointing triangle</td>
205 <literal>"pentagram"</literal> or
206 <literal>"p"</literal>
208 <td>Five-pointed star</td>
215 <term><marker_property, value></term>
218 A sequence of property value pairs can be used to specify type, color and
219 line width of the markers.
224 <term><"marker", value> or <"markerStyle", value></term>
227 Specify the type of the marker, see the table above.
232 <term><"markerEdgeColor", value> or <"markerForeground", value></term>
235 Specify the foreground color of the marker.
236 A color can be specified by a string representing a known color,
237 see <link linkend="color_list">color_list</link>.
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>.
245 <term><"markerFaceColor",value> or <"markerBackground",value></term>
248 Specify the background color of the marker.
249 A color can be specified by a string representing a known color
250 see <link linkend="color_list">color_list</link>.
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>.
258 <term><"linewidth",value> or <"thickness",value></term>
261 Specify the thickness of the edge of the marker.
262 The unit for the value is one point.
267 <term><axes_handle></term>
269 <para>This optional argument forces the scatter plot to appear inside the
270 selected axes given by <literal>axes_handle</literal> rather than inside the
271 current axes, see <link linkend="gca">gca</link>.
276 <term>polyline</term>
279 Handle of the created polyline.
286 <title>Description</title>
288 <literal>scatter(x,y)</literal> creates a scatter plot with markers centered at
289 the <literal>(x, y)</literal> set of coordinates.
290 The default type of the marker is a circle, the default color is "blue" and the default
292 This means the circle surrounding the marker has an area of 36 points squared.
295 Different sizes and colors for each marker can be specified with
296 <literal>scatter(x,y,msizes,mcolors)</literal>.
297 There are many different ways to specify marker types, marker colors and marker sizes.
298 For more details see the description of the arguments and the examples.
301 To skip an argument, just replace it with <literal>[]</literal> like in
302 <literal>scatter3(x,y,z,[],mcolors)</literal>.
306 <title>Examples</title>
308 Create 2D scatter plot
310 <programlisting role="example"><![CDATA[
311 // x and y initialisation
312 x = linspace(0,2,200);
313 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
314 // create 2D scatter plot
318 x = linspace(0,2,200)
319 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x))
325 <programlisting role="example"><![CDATA[
326 // x and y initialisation
327 x = linspace(0,2,200);
328 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
329 // specify different sizes
330 s = linspace(1,30,length(x));
331 // create 2D scatter plot
335 x = linspace(0,2,200)
336 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x))
337 s = linspace(1,30,length(x))
341 Vary marker size and color
343 <programlisting role="example"><![CDATA[
344 // x and y initialisation
345 x = linspace(0, 2, 200);
346 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
347 // specify different sizes
348 s = linspace(1, 30, length(x));
350 gcf().color_map = coolcolormap(64);
351 // colors according to x values
353 // create 2D scatter plot
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)
367 <programlisting role="example"><![CDATA[
368 // x and y initialisation
369 x = linspace(0, 2, 200);
370 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
371 // specify different sizes
372 s = linspace(1, 30, length(x));
374 gcf().color_map = coolcolormap(64);
375 // colors according to y values
377 // create 2D scatter plot
378 scatter(x, y, s, c, "fill");
381 x = linspace(0,2,200)
382 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x))
383 s = linspace(1,30,length(x))
384 gcf().color_map = coolcolormap(64);
386 scatter(x,y,s,c,"fill")
389 Specify marker symbol
391 <programlisting role="example"><![CDATA[
392 // x and y initialisation
395 // create 2D scatter plot
404 Change marker color and line width
406 <programlisting role="example"><![CDATA[
407 // x and y initialisation
410 // create 2D scatter plot
411 scatter(x, y, "markerEdgeColor",[0 .4 .4],...
412 "markerFaceColor",[0 .8 .8],...
418 scatter(x,y,"markerEdgeColor",[0 .4 .4],...
419 "markerFaceColor",[0 .8 .8],...
423 Specify subplot for scatter plot
425 <programlisting role="example"><![CDATA[
426 // x and y initialisation
427 x = linspace(0, 2, 100);
428 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x));
429 // create 2D scatter subplot
431 scatter(gca(), x, y);
432 // create 2D scatter subplot
434 scatter(gca(), x, y, "fill", "s");
437 x = linspace(0,2,100)
438 y = exp(-x).*cos(10*x) + 0.2*rand(1,length(x))
442 scatter(gca(),x,y,"fill","s")
445 Modify scatter plot after creation
447 <programlisting role="example"><![CDATA[
448 // x and y initialisation
449 t = linspace(0,1,200);
450 x = t .* cos(10*%pi*t);
451 y = t .* sin(10*%pi*t);
452 // create 2D scatter plot
456 t = linspace(0,25,200)
461 <programlisting role="example"><![CDATA[
464 p.mark_foreground = color("darkblue");
465 p.mark_background = color("darkcyan");
468 t = linspace(0,25,200)
473 p.mark_foreground = color("darkblue")
474 p.mark_background = color("darkcyan")
477 <refsection role="see also">
478 <title>See also</title>
479 <simplelist type="inline">
481 <link linkend="scatter3">scatter3</link>
484 <link linkend="plot">plot</link>
487 <link linkend="gca">gca</link>
490 <link linkend="gcf">gcf</link>
493 <link linkend="color_list">color_list</link>
496 <link linkend="polyline_properties">polyline_properties</link>
501 <title>History</title>
504 <revnumber>6.0.0</revnumber>
506 Function <function>scatter</function> introduced.