<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA - Serge Steer
 * Copyright (C) INRIA - 2008 - Jean-Baptiste Silvy
 *
 * 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="zoom_rect">
    <refnamediv>
        <refname>zoom_rect</refname>
        <refpurpose>zoom a selection of the current graphic figure</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>zoom_rect()
            zoom_rect(rect)
            zoom_rect(h)
            zoom_rect(h,rect)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>rect</term>
                <listitem>
                    <para>
                        Vector of size 4 <literal>[xmin,ymin,xmax,ymax]</literal> give the
                        rectangle to be zoomed.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>h</term>
                <listitem>
                    <para>Graphic handle of type Figure or Axes. Specify on which Axes
                        the zoom will apply.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <literal>zoom_rect</literal> function is used to perform a zoom inside a set of Axes Objects.
        </para>
        <para>
            The <literal>h</literal> input argument specifies on which Axes the zoom will apply.
            If <literal>h</literal> is a Figure handle then the zoom will apply on its Axes children.
            If <literal>h</literal> is a Axes handle then the zoom will only apply to this handle.
            If <literal>h</literal> is not specified, then the zoom is performed on the current Figure.
        </para>
        <para>
            If <literal>rect</literal> input argument is specified then the zoomed Axes <literal>zoom_box</literal>
            property is modified by the argument (see  <link linkend="axes_properties">axes_properties</link>).
            Its bounds along X and Y axis are replaced by <literal>rect</literal>.
            If <literal>rect</literal> is not specified zoom_rect is an interactive zoom. User is required to select
            a rectangle using the mouse. The new <literal>zoom_box</literal> property of zoomed axes are then computed
            by finding the intersections of the rectangle with their axes boxe.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
clf()
x=0:0.01:6*%pi;
plot2d(x,sin(x.^2))
zoom_rect([16,-1,18,1])
//more zoom
zoom_rect([16,0,16.2,1])
//back to the original
unzoom()
// zooming using axes_properties
a=gca();
a.zoom_box=[16,0,16.2,1];
a.zoom_box=[];

//zooming subplots accordingly
clf()
x=0:0.01:6*%pi;
subplot(211)
plot2d(x,cos(x))
subplot(212)
plot2d(x,cos(2*x))
rect=[3 -2 7 10]; //a rectangle specified in the current axes (last one) coordinates
zoom_rect(rect)
unzoom()
//set the global underlying axes as current
f=gcf();set('current_axes',f.children($))
rect=[0.4 0 0.6 1] //a rectangle specified in ratio of the window size
zoom_rect(rect)
rect=[0.4 0.2 0.6 0.8]; //a rectangle specified in ratio of the window size
zoom_rect(rect)

// interactive zoom on current figure
zoom_rect();
// or
zoom_rect(gcf());
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="unzoom">unzoom</link>
            </member>
            <member>
                <link linkend="axes_properties">axes_properties</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
