View Raw SPL
/*****************************************************************************
* *
* OVERPLOTALL.SPL Copyright (C) 2010-2016 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Overplots stripcharts and series *
* *
* Revisions: 13 Aug 2010 RRR Creation *
* 7 Nov 2015 RRR option for one series on all traces *
* 2 Dec 2016 RRR option for multiple series on all traces *
* *
*****************************************************************************/
#include
#if @HELP_OVERPLOTALL
OVERPLOTALL
Purpose: Overplots a series onto a stripchart.
Syntax: OVERPLOTALL(series, color, rescale)
series - A window or series to overplot
color - Optional. An integer, the overplot color. Defaults
to the next color in the overplot list.
rescale - Optional. An integer, rescale trace to fit series.
0: do not rescale
1: rescale plot (default)
Returns: Nothing, the input window or series is overplotted onto the
current window.
Example:
W1: stripchart(gnorm(1000, 1), gnorm(1000, 1))
W2: integ(w1)
W3: movavg(w2, 20);overplotall(w2, lred)
The stripchart data in W2 is synthesized by integrating
two 1000 point series of normally distributed random noise.
The series is smoothed via a 20 point moving average in
W3. The unsmoothed source in W2 is overplotted in red on to
W3 for visual comparison.
Example:
W1: stripchart(rand(1000, 4))
W2: rescale(integ(randn(1000, 1)), 0, 1);
W3: w1;overplotall(w2, lred)
W1 contains a 4 trace stripchart. W2 contains a single
series scaled between 0 and 1. W3 copies the stripchart
of W1 and the series in W2 is overplotted onto all the
traces of the stripchart in W3.
Remarks:
Use UNOVERPLOTALL to remove overplots from a stripchart.
See Also:
OVERLAY
OVERPLOT
UNOVERLAY
UNOVERPLOT
UNOVERPLOTALL
#endif
/* overplot stripcharts and overlays */
overplotall(s, color, rescale)
{
local nf, cf, cl, j, cols;
if (argc < 3)
{
if (argc < 2)
{
if (argc < 1) error(sprintf("%s - input required", __FUNC__));
color = -1;
}
rescale = 1;
}
/* check if stripchart */
if (getplottype(s) == 7)
{
/* min overlays */
nf = min(getfocus(-1), numitems(s));
/* current focus */
cf = getfocus();
loop (j = 1..nf)
{
/* set focus to each channel and overplot */
focus(j);
overplot(getitem(s, j), color, rescale);
}
/* restore original focus */
focus(cf);
}
else if (getplottype(w0) == 7)
{
/* overplot onto each trace of stripchart */
nf = getfocus(-1);
/* current focus */
cf = getfocus();
/* number of source columns */
cols = 1..numcols(s);
/* single series, overplot on all traces */
if (length(cols) == 1)
{
cols = ones(nf, 1);
}
cl = length(cols);
loop (j = 1..nf)
{
/* set focus to each channel and overplot */
focus(j);
if (j <= cl)
{
/* overplot this column on this trace */
overplot(col(s, cols[j]), color, rescale);
}
}
/* restore original focus */
focus(cf);
}
else
{
if (numitems(s) > 1)
{
/* loop through items */
loop (j = 1..numitems(s))
{
overplot(getitem(s, j), color, rescale);
}
}
else
{
/* standard overplot */
overplot(s, color, rescale);
}
}
}