<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 * Copyright (C) 2019 - Samuel GOUGEON
 *
 * 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="subplot">
    <refnamediv>
        <refname>subplot</refname>
        <refpurpose>sets the current axes to a chosen cell of the current gridded figure</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            subplot(m,n,p)
            subplot(mnp)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>m, n, p</term>
                <listitem>
                    <para>positive integers</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>mnp</term>
                <listitem>
                    <para>
                        an integer with decimal notation <literal>mnp</literal>
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            subplot(m,n,p) or subplot(mnp) virtually grids the graphics window into an m-by-n
            matrix of sub-windows, and selects the p<superscript>th</superscript> sub-window
            for receiving the forthcoming drawings.
        </para>
        <para>
            Into the grid, cells are indexed along each row, starting from the top row.
            Hence, for instance the last cell of the first row is the p = n<superscript>th</superscript>
            one. The cell on the row #i and the column #j has the index <literal>p=(i-1)*n+j</literal>.
        </para>
        <para>
            When the selected area matches exactly an existing axes, <literal>subplot(…)</literal>
            just sets it as the current axes, and returns.
        </para>
        <para>
            Otherwise, <literal>subplot(…)</literal> creates an empty axes covering the selected area,
            ready to receive forthcoming plotting contents.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
            clf
            subplot(221)
            plot2d()

            subplot(222)
            plot3d()

            subplot(2,2,3)
            param3d()

            subplot(2,2,4)
            bar3d()
 ]]></programlisting>
        <scilab:image>
            subplot(221)
            plot2d()
            subplot(222)
            plot3d()
            subplot(2,2,3)
            param3d()
            subplot(2,2,4)
            bar3d()
        </scilab:image>
        <para/>
        <para>
            <emphasis role="bold">A more complex layout</emphasis>, but still gridable:
        </para>
        <programlisting role="example"><![CDATA[
            clf
            subplot(1,2,2)
            Matplot1()
            xtitle("Matplot1() example","","")

            subplot(2,2,1)
            histplot
            delete(findobj("type","Legend"))

            subplot(2,2,3)
            title("Smaller plots:", "fontsize",3)

            subplot(2,4,5)
            polarplot()

            subplot(2,4,6)
            param3d()
            xtitle("","","","")
 ]]></programlisting>
        <scilab:image>
            clf
            subplot(1,2,2)
            Matplot1()
            xtitle("Matplot1() example","","")

            subplot(2,2,1)
            histplot
            delete(findobj("type","Legend"))

            subplot(2,2,3)
            title("Smaller plots:", "fontsize",3)

            subplot(2,4,5)
            polarplot()

            subplot(2,4,6)
            param3d()
            xtitle("","","","")
            gcf().axes_size = [670 400];
        </scilab:image>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="xsetech">xsetech</link>
            </member>
            <member>
                <link linkend="newaxes">newaxes</link>
            </member>
            <member>
                <link linkend="axes_properties">axes_properties</link>
            </member>
            <member>
                <link linkend="plotframe">plotframe</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
