<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) ENPC - Jean-Philippe Chancelier
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<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="Matplot1">
    <refnamediv>
        <refname>Matplot1</refname>
        <refpurpose>
            2D plot of a matrix using colors
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>Matplot1(a, rect)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>a</term>
                <listitem>
                    <para>
                        a real matrix of size <literal>(n1,n2)</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>rect</term>
                <listitem>
                    <para>
                        <literal>[xmin, ymin, xmax, ymax]</literal>.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            The entries of matrix <code>int(a)</code> are used as colormap entries
            in the current colormap.  <varname>rect</varname> specifies a rectangle in the
            current scale and the matrix is drawn inside this rectangle. Each matrix
            entry will be rendered as a small rectangle filled with its associated
            color. If a matrix entry is outside the colormap, the corresponding rectangle
            is not displayed.
        </para>
        <para>
            Enter the command <code>Matplot1()</code> to see a demo.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
clf();
ax = gca();//get current axes handle
ax.data_bounds = [0, 0; 10, 10]; //set the data_bounds
ax.box = 'on'; //draw a box
a = 5*ones(11,11);
a(2:10, 2:10) = 4;
a(5:7, 5:7) = 2;
// first matrix in rectangle [1,1,3,3]
Matplot1(a, [1,1,3,3])
a = ones(10,10);
a = 3*tril(a)+ 2*a;
// second matrix in rectangle [5,6,7,8]
Matplot1(a,[5,6,7,8])
 ]]></programlisting>
        <scilab:image>
            ax=gca();//get current axes handle
            ax.data_bounds=[0,0;10,10];//set the data_bounds
            ax.box='on'; //draw a box
            a=5*ones(11,11); a(2:10,2:10)=4; a(5:7,5:7)=2;
            // first matrix in rectangle [1,1,3,3]
            Matplot1(a,[1,1,3,3])
            a=ones(10,10); a= 3*tril(a)+ 2*a;
            // second matrix in rectangle [5,6,7,8]
            Matplot1(a,[5,6,7,8])
        </scilab:image>
        <programlisting role="example"><![CDATA[
//--- (animation)
n=100;

clf();
f = gcf();//get current figure handle
ax = gca();//get current axes handle
ax.data_bounds = [0, 0 ; 10, 10];//set the data_bounds
ax.box = 'on'; //draw a box
o = ones(n, n);
a = 3 * tril(o, -n) + 2*o;
a = a + a';
Matplot1(a, [0, 2, 7, 9])
mp = gce();
for k = (-n + 1):n,
  a = 3 * tril(o, k) + 2 * o;
  a = a + a';
  k1 = 3 * (k + 100) / 200;
  mp.data = a;
  mp.rect = [k1, 2, k1 + 7, 9];
  sleep(8); // Slow down the simulation
end
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="colormap">colormap</link>
            </member>
            <member>
                <link linkend="plot2d">plot2d</link>
            </member>
            <member>
                <link linkend="Matplot">Matplot</link>
            </member>
            <member>
                <link linkend="grayplot">grayplot</link>
            </member>
            <member>
                <link linkend="Matplot_properties">Matplot_properties</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
