View Raw SPL
/*****************************************************************************
*                                                                            *
*   BAR3D.SPL    Copyright (C) 2011 DSP Development Corporation              *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Converts 3D data to a 3D bar plot                           *
*                                                                            *
*   Revisions:   20 Jan 2011  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#include 

#if @HELP_BAR3D

    BAR3D

    Purpose: Converts 3D data to a 3D bar chart.

    Syntax:  BAR3D(win, gap)

                    win - Optional. A window, the target window. Defaults
                          to the current window.

                    gap - Optional. An integer, the bar gap flag.
                            0: do not display gaps between bars (default)
                            1: display gaps between bars

    Returns: Nothing, the target window displays 3D bars.

    Example:
             W1: rand(10, 4);bar3d()
             W2: W1;bar3d(1)

             W1 contains a 10x4 array that is displayed as 3D bars with
             no gaps. W2 contains the same data displayed as a 3D bar
             chart with gaps bewteen each bar.

    Remarks:
             See COLSHADER, ROWSHADER and SHADEWITH to apply color
             shading to the bars.

    See Also:
             Bars
             Bargap
             Barstyle
#endif


/* set 3D data to bars */
bar3d(w, gap)
{
        local winnum;

        /* parse input */
        (winnum, gap) = bar3d_parse_args(w, gap);

        /* convert to window */
        w = castwindow(winnum);

        /* 3D */
        setplottype(w, 4);

        /* bars */
        setplotstyle(w, 3);

        /* set gaps between individual bars */
        bargap(w, gap);

        /* rescale */
        autoscale(w);
}


/* get bar3d input */
bar3d_parse_args(w, gap)
{
        if (argc < 2)
        {
                if (argc < 1)
                {
                        w = refwindow(w0);
                }
                
                if (isscalar(w))
                {
                        gap = w;
                        w   = refwindow(w0);
                }
                else
                {
                        gap = 0;
                }
        }

        /* return window number */
        winnum = getwnum(w);

        return(winnum, gap);
}