Manage vectors of colors in name2rgb.
[scilab.git] / scilab / modules / graphics / help / en_US / 2d_plot / scatter3.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) Scilab Enterprises - 2015 - 2012 - Juergen Koch
5  *
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at
10  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11  *
12  -->
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:lang="en" xml:id="scatter3">
14     <refnamediv>
15         <refname>scatter3</refname>
16         <refpurpose>3D scatter plot</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>
21           scatter3(x,y,z,&lt;s&gt;,&lt;c&gt;,&lt;"fill"&gt;,&lt;marker&gt;,&lt;marker_property,value&gt;)
22           scatter3(&lt;axes_handle&gt;,...)
23         </synopsis>
24     </refsynopsisdiv>
25     <refsection>
26         <title>Arguments</title>
27         <variablelist>
28             <varlistentry>
29                 <term>x</term>
30                 <listitem>
31                     <para>
32                         A column or row vector of n real numbers
33                         specifying the x positions of the markers center.
34                         x, y and z must be vectors of the same length.
35                     </para>
36                 </listitem>
37             </varlistentry>
38             <varlistentry>
39                 <term>y</term>
40                 <listitem>
41                     <para>
42                         A column or row vector of n real numbers
43                         specifying the y positions of the markers center.
44                         x, y and z must be vectors of the same length.
45                     </para>
46                 </listitem>
47             </varlistentry>
48             <varlistentry>
49                 <term>z</term>
50                 <listitem>
51                     <para>
52                         A column or row vector of n real numbers
53                         specifying the y positions of the markers center.
54                         x, y and z must be vectors of the same length.
55                     </para>
56                 </listitem>
57             </varlistentry>
58             <varlistentry>
59                 <term>s</term>
60                 <listitem>
61                     <para>
62                         Specifying the sizes of the markers.
63                         To plot each marker with equal size, specify s as a scalar.
64                         To plot each marker with a diferent size, specify s as a vector with length equal to the length of x, y and z.
65                         The units for s is points squared with a default value of 36 points squared.
66                         The size equals the area of the circle surrounding the marker.
67                     </para>
68                 </listitem>
69             </varlistentry>
70             <varlistentry>
71                 <term>c</term>
72                 <listitem>
73                     <para>
74                         Specifying the colors of the markers.
75                         To plot each marker with the same color, specify c as a string representing a known color, see <link linkend="color_list">color_list</link>.
76                         A color can also be specified by a vector of 3 RGB values.
77                         RGB values correspond to red, green and blue intensity between 0 and 1.
78                         To plot each marker with a diferent color, specify c as a vector with length equal to the length of x, y and z.
79                         The values of c are linarly mapped to the colors in the current colormap.
80                         Colors can also by specified by a matrix of RGB values or a vector of strings representing known colors.
81                         A matrix of RGB values has 3 columns and the number of rows equals the length of x, y and z.
82                         The default color is "blue". 
83                     </para>
84                 </listitem>
85             </varlistentry>
86             <varlistentry>
87                 <term>&lt;"fill"&gt;</term>
88                 <listitem>
89                     <para>
90                         This string indicates that the markers are filled with colors.
91                         The markers background colors are set using the values of c.
92                         If c is not specified the fill color can be defined by the marker property "markerFaceColor" or "markerBackgroundColor".
93                         The default color is "blue".  
94                     </para>
95                 </listitem>
96             </varlistentry>
97             <varlistentry>
98                 <term>&lt;marker&gt;</term>
99                 <listitem>
100                     <para>
101                         Select the type of the marker.
102                         The figure below shows the 15 different marker types.
103                     </para>
104                     <para>
105                         <inlinemediaobject>
106                             <imageobject>
107                                 <imagedata fileref="../../images/marks.svg"/>
108                             </imageobject>
109                         </inlinemediaobject>
110                     </para>
111                     <para>
112                         Marker types are specified by strings, see the table below.
113                     </para>
114                     <para>
115                     <informaltable border="1">
116                         <tr>
117                             <td>
118                                 String
119                             </td>
120                             <td>
121                                 Marker type
122                             </td>
123                         </tr>
124                         <tr>
125                             <td>
126                                 <literal>"."</literal>
127                             </td>
128                             <td>Point</td>
129                         </tr>
130                         <tr>
131                             <td>
132                                 <literal>"+"</literal>
133                             </td>
134                             <td>Plus sign</td>
135                         </tr>
136                         <tr>
137                             <td>
138                                 <literal>"x"</literal>
139                             </td>
140                             <td>Cross</td>
141                         </tr>
142                         <tr>
143                             <td>
144                                 <literal>"circle plus"</literal>
145                             </td>
146                             <td>Circle with plus</td>
147                         </tr>
148                         <tr>
149                             <td>
150                                 <literal>"filled diamond"</literal>
151                             </td>
152                             <td>Filled diamond</td>
153                         </tr>
154                         <tr>
155                             <td>
156                                 <literal>"d"</literal> or
157                                 <literal>"diamond"</literal>
158                             </td>
159                             <td>Diamond</td>
160                         </tr>
161                         <tr>
162                             <td>
163                                 <literal>"^"</literal>
164                             </td>
165                             <td>Upward-pointing triangle</td>
166                         </tr>
167                         <tr>
168                             <td>
169                                 <literal>"v"</literal>
170                             </td>
171                             <td>Downward-pointing triangle</td>
172                         </tr>
173                         <tr>
174                             <td>
175                                 <literal>"diamond plus"</literal>
176                             </td>
177                             <td>Diamond with plus</td>
178                         </tr>
179                         <tr>
180                             <td>
181                                 <literal>"o"</literal>
182                             </td>
183                             <td>Circle (default)</td>
184                         </tr>
185                         <tr>
186                             <td>
187                                 <literal>"*"</literal>
188                             </td>
189                             <td>Asterisk</td>
190                         </tr>
191                         <tr>
192                             <td>
193                                 <literal>"s"</literal> or
194                                 <literal>"square"</literal>
195                             </td>
196                             <td>Square</td>
197                         </tr>
198                         <tr>
199                             <td>
200                                 <literal>"&gt;"</literal>
201                             </td>
202                             <td>Right-pointing triangle</td>
203                         </tr>
204                         <tr>
205                             <td>
206                                 <literal>"&lt;"</literal>
207                             </td>
208                             <td>Left-pointing triangle</td>
209                         </tr>
210                         <tr>
211                             <td>
212                                 <literal>"pentagram"</literal> or
213                                 <literal>"p"</literal>
214                             </td>
215                             <td>Five-pointed star</td>
216                         </tr>
217                      </informaltable>
218                     </para>
219                 </listitem>
220             </varlistentry>
221             <varlistentry>
222                 <term>&lt;marker_property,value&gt;</term>
223                 <listitem>
224                     <para>
225                          A sequence of property value pairs can be used to specify type, color and line width of the markers.
226                     </para>
227                 </listitem>
228             </varlistentry>
229             <varlistentry>
230                 <term>&lt;"marker",value&gt; or &lt;"markerStyle",value&gt;</term>
231                 <listitem>
232                     <para>
233                         Specify the type of the marker, see the table above.
234                     </para>
235                 </listitem>
236             </varlistentry>
237             <varlistentry>
238                 <term>&lt;"markerEdgeColor",value&gt; or &lt;"markerForground",value&gt;</term>
239                 <listitem>
240                     <para>
241                         Specify the foreground color of the marker.
242                         A color can be specified by a string representing a known color, see <link linkend="color_list">color_list</link>.
243                         A color can also be specified by a vector of 3 RGB values.
244                         RGB values correspond to red, green and blue intensity between 0 and 1.
245                         This option is superseded by argument c.
246                     </para>
247                 </listitem>
248             </varlistentry>
249             <varlistentry>
250                 <term>&lt;"markerFaceColor",value&gt; or &lt;"markerBackground",value&gt;</term>
251                 <listitem>
252                     <para>
253                         Specify the background color of the marker.
254                         A color can be specified by a string representing a known color, see <link linkend="color_list">color_list</link>.
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 c.
258                     </para>
259                 </listitem>
260             </varlistentry>
261             <varlistentry>
262                 <term>&lt;"linewidth",value&gt; or &lt;"thickness",value&gt;</term>
263                 <listitem>
264                     <para>
265                         Specify the thickness of the edge of the marker.
266                         The unit for the value is one point.
267                     </para>
268                 </listitem>
269             </varlistentry>
270             <varlistentry>
271                 <term>&lt;axes_handle&gt;</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         </variablelist>
280     </refsection>
281     <refsection>
282         <title>Description</title>
283         <para>
284             <literal>scatter3(x,y)</literal> creates a scatter plot with markers at the locations specified by x and y.
285             The default type of the marker is a circle, the default color is "blue" and the default size is 36.
286             This means the circle surrounding the marker has an area of 36 points squared. 
287         </para>
288         <para>
289             Using <literal>scatter3(x,y,s,c)</literal> different sizes and colors for each marker can be specified. 
290             There are many different ways to specify marker types, marker colors and marker sizes.
291             For more details see the description of the arguments and the examples.
292         </para>
293     </refsection>
294     <refsection>
295         <title>Remarks</title>
296         <para>
297             If you want to specify colors without specifying sizes use <literal>scatter3(x,y,[],c)</literal>. 
298         </para>
299     </refsection>
300     <refsection>
301         <title>Examples</title>
302         <para>
303             Create 3D scatter plot
304         </para>
305         <programlisting role="example"><![CDATA[
306 // x, y and z initialisation
307 t = 1:200
308 x = t.*cos(t).*sin(t)
309 y = t.*sin(t).*sin(t)
310 z = t.*cos(t)
311 // create 3D scatter plot
312 scatter3(x,y,z)
313 // modify rotation angles
314 set(gca(),"rotation_angles",[60,45])
315  ]]></programlisting>
316         <scilab:image>
317 t = 1:200
318 x = t.*cos(t).*sin(t)
319 y = t.*sin(t).*sin(t)
320 z = t.*cos(t)
321 scatter3(x,y,z)
322 set(gca(),"rotation_angles",[60,45])
323         </scilab:image>
324         <para>
325            Vary marker size
326         </para>
327         <programlisting role="example"><![CDATA[
328 // x, y and z initialisation
329 t = 1:200
330 x = t.*cos(t).*sin(t)
331 y = t.*sin(t).*sin(t)
332 z = t.*cos(t)
333 // size according to radius
334 s = linspace(50,1,length(t))
335 // create 3D scatter plot
336 scatter3(x,y,z,s)
337 // modify rotation angles
338 set(gca(),"rotation_angles",[60,45])
339  ]]></programlisting>
340         <scilab:image>
341 t = 1:200
342 x = t.*cos(t).*sin(t)
343 y = t.*sin(t).*sin(t)
344 z = t.*cos(t)
345 s = linspace(50,1,length(t))
346 scatter3(x,y,z,s)
347 set(gca(),"rotation_angles",[60,45])
348         </scilab:image>
349         <para>
350            Vary marker sie and color
351         </para>
352         <programlisting role="example"><![CDATA[
353 // x, y and z initialisation
354 t = 1:200
355 x = t.*cos(t).*sin(t)
356 y = t.*sin(t).*sin(t)
357 z = t.*cos(t)
358 // size according to radius
359 s = linspace(50,1,length(t))
360 // set color map
361 set(gcf(),"color_map",coolcolormap(64))
362 // color according to radius
363 c = t
364 // create 3D scatter plot
365 scatter3(x,y,z,s,c)
366 // modify rotation angles
367 set(gca(),"rotation_angles",[60,45])
368  ]]></programlisting>
369         <scilab:image>
370 t = 1:200
371 x = t.*cos(t).*sin(t)
372 y = t.*sin(t).*sin(t)
373 z = t.*cos(t)
374 s = linspace(50,1,length(t))
375 set(gcf(),"color_map",coolcolormap(64))
376 c = t
377 scatter3(x,y,z,s,c)
378 set(gca(),"rotation_angles",[60,45])
379         </scilab:image>
380         <para>
381            Fill the markers
382         </para>
383         <programlisting role="example"><![CDATA[
384 // x, y and z initialisation
385 z = linspace(0,25,200)
386 x = z.*cos(z)
387 y = z.*sin(z)
388 // create 3D scatter plot
389 scatter3(x,y,z,"fill")
390 // modify rotation angles
391 set(gca(),"rotation_angles",[60,45])
392  ]]></programlisting>
393         <scilab:image>
394 z = linspace(0,25,200)
395 x = z.*cos(z)
396 y = z.*sin(z)
397 scatter3(x,y,z,"fill")
398 set(gca(),"rotation_angles",[60,45])
399         </scilab:image>
400         <para>
401             Specify marker symbol
402         </para>
403         <programlisting role="example"><![CDATA[
404 // x, y and z initialisation
405 z = linspace(0,25,200)
406 x = z.*cos(z)
407 y = z.*sin(z)
408 // create 3D scatter plot
409 scatter3(x,y,z,"*")
410 // modify rotation angles
411 set(gca(),"rotation_angles",[60,45])
412  ]]></programlisting>
413         <scilab:image>
414 z = linspace(0,25,200)
415 x = z.*cos(z)
416 y = z.*sin(z)
417 scatter3(x,y,z,"*")
418 set(gca(),"rotation_angles",[60,45])
419         </scilab:image>
420         <para>
421             Change marker edge and face color
422         </para>
423         <programlisting role="example"><![CDATA[
424 // x, y and z initialisation
425 z = linspace(0,25,200)
426 x = z.*cos(z)
427 y = z.*sin(z)
428 // create 3D scatter plot
429 scatter3(x,y,z,...
430         "markerEdgeColor","black",...
431         "markerFaceColor",[0 .8 .8])
432 // modify rotation angles
433 set(gca(),"rotation_angles",[60,45])
434  ]]></programlisting>
435         <scilab:image>
436 z = linspace(0,25,200)
437 x = z.*cos(z)
438 y = z.*sin(z)
439 scatter3(x,y,z,...
440         "markerEdgeColor","black",...
441         "markerFaceColor",[0 .8 .8])
442 set(gca(),"rotation_angles",[60,45])
443         </scilab:image>
444         <para>
445             Specify subplot for scatter plot
446         </para>
447         <programlisting role="example"><![CDATA[
448 // x, y and z initialisation
449 n = 20
450 [x,y] = meshgrid(linspace(-2,2,n))
451 z = exp(-x.^2-y.^2)
452 // create 3D scatter subplot
453 subplot(2,1,1)
454 scatter3(gca(),x(:),y(:),z(:))
455 // modify rotation angles
456 set(gca(),"rotation_angles",[60,45])
457 // create 3D scatter subplot
458 subplot(2,1,2)
459 scatter3(gca(),x(:),y(:),z(:),"markerFaceColor",[0 .8 .8])
460 // modify rotation angles
461 set(gca(),"rotation_angles",[60,45])
462  ]]></programlisting>
463         <scilab:image>
464 n = 20
465 [x,y] = meshgrid(linspace(-2,2,n))
466 z = exp(-x.^2-y.^2)
467 subplot(2,1,1)
468 scatter3(gca(),x(:),y(:),z(:))
469 set(gca(),"rotation_angles",[60,45])
470 subplot(2,1,2)
471 scatter3(gca(),x(:),y(:),z(:),"markerFaceColor",[0 .8 .8])
472 set(gca(),"rotation_angles",[60,45])        </scilab:image>
473         <para>
474             Modify scatter plot after creation
475         </para>
476         <programlisting role="example"><![CDATA[
477 // x, y and z initialisation
478 t = 1:200
479 x = t.*cos(t).*sin(t)
480 y = t.*sin(t).*sin(t)
481 z = t.*cos(t)
482 // size according to radius
483 s = linspace(50,1,length(t))
484 // create 3D scatter plot
485 scatter3(x,y,z,s)
486 // modify rotation angles
487 set(gca(),"rotation_angles",[60,45])
488  ]]></programlisting>
489         <scilab:image>
490 t = 1:200
491 x = t.*cos(t).*sin(t)
492 y = t.*sin(t).*sin(t)
493 z = t.*cos(t)
494 s = linspace(50,1,length(t))
495 scatter3(x,y,z,s)
496 set(gca(),"rotation_angles",[60,45])
497         </scilab:image>
498         <programlisting role="example"><![CDATA[
499 // get polyline
500 polyLine = gce()
501 // modify ployline 
502 polyLine.mark_foreground = addcolor([0.5 0 0])
503 polyLine.mark_background = addcolor([0.5 0.5 0])
504  ]]></programlisting>
505         <scilab:image>
506 t = 1:200
507 x = t.*cos(t).*sin(t)
508 y = t.*sin(t).*sin(t)
509 z = t.*cos(t)
510 s = linspace(50,1,length(t))
511 scatter3(x,y,z,s)
512 set(gca(),"rotation_angles",[60,45])
513 polyLine = gce()
514 // modify ployline 
515 polyLine.mark_foreground = addcolor([0.5 0 0])
516 polyLine.mark_background = addcolor([0.5 0.5 0])
517         </scilab:image>
518     </refsection>
519     <refsection role="see also">
520         <title>See Also</title>
521         <simplelist type="inline">
522             <member>
523                 <link linkend="scatter">scatter</link>
524             </member>
525             <member>
526                 <link linkend="param3d">param3d</link>
527             </member>
528             <member>
529                 <link linkend="gca">gca</link>
530             </member>
531             <member>
532                 <link linkend="gce">gce</link>
533             </member>
534             <member>
535                 <link linkend="gcf">gcf</link>
536             </member>
537             <member>
538                 <link linkend="color_list">color_list</link>
539             </member>
540             <member>
541                 <link linkend="polyline_properties">polyline_properties</link>
542             </member>
543         </simplelist>
544     </refsection>
545 </refentry>