37e6bde0ade07f7aeb4d1b2f9e45adfcee955719
[scilab.git] / scilab / modules / graphics / help / en_US / 2d_plot / contourf.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) ENPC - Jean-Philippe Chancelier
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-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:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:id="contourf" xml:lang="en">
14     <refnamediv>
15         <refname>contourf</refname>
16         <refpurpose>filled level curves of a surface on a 2D plot</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>contourf(x,y,z,nz,[style,strf,leg,rect,nax])</synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Arguments</title>
24         <variablelist>
25             <varlistentry>
26                 <term>x,y</term>
27                 <listitem>
28                     <para>two real row vectors of size n1 and n2: the grid.</para>
29                 </listitem>
30             </varlistentry>
31             <varlistentry>
32                 <term>z</term>
33                 <listitem>
34                     <para>real matrix of size (n1,n2), the values of the
35                         function.
36                     </para>
37                 </listitem>
38             </varlistentry>
39             <varlistentry>
40                 <term>nz</term>
41                 <listitem>
42                     <para>the level values or the number of levels.</para>
43                     <variablelist>
44                         <varlistentry>
45                             <term>-</term>
46                             <listitem>
47                                 <para>
48                                     If <literal>nz</literal> is an integer, its value gives
49                                     the number of level curves equally spaced from zmin to zmax as
50                                     follows:
51                                 </para>
52                                 <programlisting role="no-scilab-exec"><![CDATA[ 
53 z= zmin + (1:nz)*(zmax-zmin)/(nz+1)
54  ]]></programlisting>
55                                 <para>
56                                     Note: that the <literal>zmin</literal> and
57                                     <literal>zmax</literal> levels are not drawn (generically they
58                                     are reduced to points) but they can be added with
59                                 </para>
60                                 <programlisting role="no-scilab-exec"><![CDATA[ 
61 [im,jm] = find(z == zmin);     // or zmax 
62 plot2d(x(im)',y(jm)',-9,"000")
63  ]]></programlisting>
64                             </listitem>
65                         </varlistentry>
66                         <varlistentry>
67                             <term>-</term>
68                             <listitem>
69                                 <para>
70                                     If <literal>nz</literal> is a vector,
71                                     <literal>nz(i)</literal> gives the value of the ith level
72                                     curve.
73                                 </para>
74                             </listitem>
75                         </varlistentry>
76                     </variablelist>
77                 </listitem>
78             </varlistentry>
79             <varlistentry>
80                 <term>style,strf,leg,rect,nax</term>
81                 <listitem>
82                     <para>
83                         see <literal>plot2d</literal>. The argument
84                         <literal>style</literal> gives the colors which are to be used for
85                         level curves. It must have the same size as the number of
86                         levels.
87                     </para>
88                 </listitem>
89             </varlistentry>
90         </variablelist>
91     </refsection>
92     <refsection>
93         <title>Description</title>
94         <para>
95             <literal>contourf</literal> paints surface between two consecutives
96             level curves of a surface <literal>z=f(x,y)</literal> on a 2D plot. The
97             values of <literal>f(x,y)</literal> are given by the matrix
98             <literal>z</literal> at the grid points defined by <literal>x</literal>
99             and <literal>y</literal>.
100         </para>
101         <para>You can change the format of the floating point number printed on
102             the levels by using <literal>xset("fpf",string)</literal> where
103             <literal>string</literal> gives the format in C format syntax (for example
104             <literal>string="%.3f"</literal>). Use <literal>string=""</literal> to
105             switch back to default format.
106         </para>
107         <para>
108             Enter the command <literal>contourf()</literal> to see a
109             demo.
110         </para>
111     </refsection>
112     <refsection>
113         <title>Examples</title>
114         <programlisting role="example"><![CDATA[ 
115 contourf(1:10,1:10,rand(10,10),5,1:5,"011"," ",[0,0,11,11])
116  ]]></programlisting>
117         <scilab:image>
118             contourf(1:10,1:10,rand(10,10),5,1:5,"011"," ",[0,0,11,11])
119         </scilab:image>
120         <programlisting role="example"><![CDATA[ 
121 function z=peaks(x,y)
122 x1=x(:).*.ones(1,size(y,'*'));
123 y1=y(:)'.*.ones(size(x,'*'),1);
124 z =  (3*(1-x1).^2).*exp(-(x1.^2) - (y1+1).^2) ... 
125    - 10*(x1/5 - x1.^3 - y1.^5).*exp(-x1.^2-y1.^2) ... 
126    - 1/3*exp(-(x1+1).^2 - y1.^2) 
127 endfunction
128
129 function z=peakit()
130 x=-4:0.1:4;y=x;z=peaks(x,y);
131 endfunction
132
133 z=peakit();
134
135 levels=[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8];
136 m=size(levels,'*');
137 n = fix(3/8*m);
138 r = [(1:n)'/n; ones(m-n,1)];
139 g = [zeros(n,1); (1:n)'/n; ones(m-2*n,1)];
140 b = [zeros(2*n,1); (1:m-2*n)'/(m-2*n)];
141 h = [r g b];
142 xset('colormap',h);
143 xset('fpf',' ');
144 clf();
145 contourf([],[],z,[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8],0*ones(1,m))
146
147 xset('fpf','');
148 clf();
149 contourf([],[],z,[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8]);
150  ]]></programlisting>
151         <scilab:image>
152             function z=peaks(x,y)
153             x1=x(:).*.ones(1,size(y,'*'));
154             y1=y(:)'.*.ones(size(x,'*'),1);
155             z =  (3*(1-x1).^2).*exp(-(x1.^2) - (y1+1).^2) ... 
156             - 10*(x1/5 - x1.^3 - y1.^5).*exp(-x1.^2-y1.^2) ... 
157             - 1/3*exp(-(x1+1).^2 - y1.^2) 
158             endfunction
159             
160             function z=peakit()
161             x=-4:0.1:4;y=x;z=peaks(x,y);
162             endfunction
163             
164             z=peakit();
165             
166             levels=[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8];
167             m=size(levels,'*');
168             n = fix(3/8*m);
169             r = [(1:n)'/n; ones(m-n,1)];
170             g = [zeros(n,1); (1:n)'/n; ones(m-2*n,1)];
171             b = [zeros(2*n,1); (1:m-2*n)'/(m-2*n)];
172             h = [r g b];
173             xset('colormap',h);
174             xset('fpf',' ');
175             clf();
176             contourf([],[],z,[-6:-1,-logspace(-5,0,10),logspace(-5,0,10),1:8],0*ones(1,m))
177             
178         </scilab:image>
179     </refsection>
180     <refsection role="see also">
181         <title>See Also</title>
182         <simplelist type="inline">
183             <member>
184                 <link linkend="contour">contour</link>
185             </member>
186             <member>
187                 <link linkend="fcontour">fcontour</link>
188             </member>
189             <member>
190                 <link linkend="fcontour2d">fcontour2d</link>
191             </member>
192             <member>
193                 <link linkend="contour2di">contour2di</link>
194             </member>
195             <member>
196                 <link linkend="plot2d">plot2d</link>
197             </member>
198             <member>
199                 <link linkend="xset">xset</link>
200             </member>
201         </simplelist>
202     </refsection>
203 </refentry>