<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA - Farid Belahcene
 *
 * 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="barhomogenize">
    <refnamediv>
        <refname>barhomogenize</refname>
        <refpurpose>homogenize all the bars included in the current working axes</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            barhomogenize()
            barhomogenize(h)
            barhomogenize([h,] style)
            barhomogenize([h,] width)
            barhomogenize([h,] style, width)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>h</term>
                <listitem>
                    <para>
                    an axes handle: The axes where barhomogenize() must be applied. Default
                    <literal>h=gca()</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>style</term>
                <listitem>
                    <para>
                        word <literal>'grouped'</literal> (default) or <literal>'stacked'</literal>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>width</term>
                <listitem>
                    <para>a decimal number <literal>0 &lt; width &lt;= 1</literal>, setting the
                    width of bars, as a fraction of the maximum allowed width. Default: 0.8.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            If there are several bar calls, the <literal>barhomogenize</literal> function
            allows to homogenize the width and style of all bars (i.e which has the
            <literal>polyline_style</literal> type 6) included in the current working axes.
            These bars must have the same x data.
        </para>
        <para>
            <literal>barhomogenize( ) :</literal> takes the default values <literal>h=gca(),
            width=0.8, style='grouped'.</literal>
        </para>
        <para>
            <literal>barhomogenize(h,...) :</literal> defines the current axes where the
            drawing is performed.
        </para>
        <para>
            <literal>barhomogenize(...,style,...) :</literal> defines how the bars are
            drawn. The 'grouped' option allows to center the M polylines versus each
            components of x, and the 'stacked' option allows to stack them.
        </para>
        <para>
            <literal>barhomogenize(...,width) :</literal> defines the width of the
            bar(s) in percentage (generally: 0&lt;width&lt;=1).
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <para>
        <emphasis role="bold">First example:</emphasis> creation of 1 yellow bar (i.e 1 polyline
        with polyline_style=6) and 3 bars (i.e 3 polylines with polyline_style=6)
        </para>
        <programlisting role="example"><![CDATA[
            subplot(2,3,1)
            xtitle('ex1: creation of 1 yellow bar and 3 bars')
            x=1:3;
            y1=1:3;
            y2=[4 3 5;6 7 8;9 10 11];
            bar(x,y1,'yellow');bar(x,y2);

            // grouped homogenization of these 4 bars
            subplot(2,3,2)
            xtitle('grouped homogenization')
            x=1:3;
            y1=1:3;
            y2=[4 3 5;6 7 8;9 10 11];
            bar(x,y1,'yellow');bar(x,y2);
            barhomogenize();

            // stacked homogenization of the 4 bars
            subplot(2,3,3)
            xtitle('stacked homogenization')
            x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
            bar(x,y1,'yellow');bar(x,y2);
            barhomogenize('stacked',1);
]]></programlisting>
        <scilab:image>
            gcf().axes_size = [800 270];
            subplot(1,3,1)
            xtitle('ex1: creation of 1 yellow bar and 3 bars')
            x=1:3;
            y1=1:3;
            y2=[4 3 5;6 7 8;9 10 11];
            bar(x,y1,'yellow');bar(x,y2);

            subplot(1,3,2)
            xtitle('grouped homogenization')
            x=1:3;
            y1=1:3;
            y2=[4 3 5;6 7 8;9 10 11];
            bar(x,y1,'yellow');bar(x,y2);
            barhomogenize();

            subplot(1,3,3)
            xtitle('stacked homogenization')
            x=1:3; y1=1:3; y2=[4 3 5;6 7 8;9 10 11];
            bar(x,y1,'yellow');bar(x,y2);
            barhomogenize('stacked',1);
        </scilab:image>
        <para>
            <emphasis role="bold">Second example : </emphasis>creation of 1 red bar (i.e 1 polyline
            with polyline_style=6) and 2 polylines with type=1 (calling plot function).
        </para>
        <programlisting role="example"><![CDATA[
            subplot(2,3,4)
            xtitle('ex2: creation of 1 bar and 2 polylines')
            x=1:10;
            y=sin(x)/2;
            bar(x,y,'red')
            x1=1:10;
            y1=[sin(x);cos(x)]
            plot(x1',y1')

            // modify the polyline_style type of the second polyline from plot (this polyline becomes a bar)
            subplot(2,3,5)
            xtitle('transformation of the second polyline to bar')
            x=1:10;
            y=sin(x)/2;
            bar(x,y,'red')
            x1=1:10;
            y1=[sin(x);cos(x)]
            plot(x1',y1')
            e=gce();
            e2=e.children(2);
            e2.polyline_style=6;

            // homogenization of the first bar (from bar function) and second bar (from the modification).
            subplot(2,3,6)
            xtitle('grouped homogenization')
            x=1:10;
            y=sin(x)/2;
            bar(x,y,'red')
            x1=1:10;
            y1=[sin(x);cos(x)]
            plot(x1',y1')
            e=gce();
            e2=e.children(2);
            e2.polyline_style=6;
            barhomogenize();
            // change the style and the width
            //barhomogenize('stacked',0.5);
            //barhomogenize('stacked',1);
 ]]></programlisting>
        <scilab:image>
            gcf().axes_size = [800 270];
            // Second example : creation of 1 red bar (i.e 1 polyline with polyline_style=6)
            //  and 2 polylines with type=1 (calling plot function)
            subplot(1,3,1)
            xtitle('ex2: creation of 1 bar and 2 polylines')
            x=1:10;
            y=sin(x)/2;
            bar(x,y,'red')
            x1=1:10;
            y1=[sin(x);cos(x)]
            plot(x1',y1')

            // modify the polyline_style type of the second polyline from plot (this polyline becomes a bar)
            subplot(1,3,2)
            xtitle('transformation of the second polyline to bar')
            x=1:10;
            y=sin(x)/2;
            bar(x,y,'red')
            x1=1:10;
            y1=[sin(x);cos(x)]
            plot(x1',y1')
            e=gce();
            e2=e.children(2);
            e2.polyline_style=6;

            // homogenization of the first bar (from bar function) and second bar (from the modification).
            subplot(1,3,3)
            xtitle('grouped homogenization')
            x=1:10;
            y=sin(x)/2;
            bar(x,y,'red')
            x1=1:10;
            y1=[sin(x);cos(x)]
            plot(x1',y1')
            e=gce();
            e2=e.children(2);
            e2.polyline_style=6;
            barhomogenize();
            // change the style and the width
            //barhomogenize('stacked',0.5);
            //barhomogenize('stacked',1);
        </scilab:image>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="bar">bar</link>
            </member>
            <member>
                <link linkend="histplot">histplot</link>
            </member>
            <member>
                <link linkend="polyline_properties">polyline_properties</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
