stepline (replaces SteplinePlot)


The stepline function creates a stepped line plot by connecting data points with a stepped line. This is an efficient non-class equivalent to the CPlotView:StepLine method. The x and y points at the same array index are presumed to correspond to the same point. This function does not plot x or y error bars; to include error bars, use steplineerr. The data for x and y are in a lua array (1-dimensional indexed table). This function creates a new plot window and returns a CPlotView object and a CPlot object for the plot and the plot series it creates. These objects can be used to enhance or add to the plot or extract plot data for further analysis. There are four similar versions of this command which are compared here.

Syntax

CPlotView, CPlot = stepline( x, y )

CPlotView, CPlot = stepline( x, y, sLabelX )

CPlotView, CPlot = stepline( x, y, sLabelX, sLabelY )

CPlotView, CPlot = stepline( x, y, sLabelX, sLabelY, sCaption )

CPlotView, CPlot = stepline( x, y, sLabelX, sLabelY, sCaption, sWindowTitle )

bullet.gif    x is a 1-dimensional array containing the x values.

bullet.gif    y is a 1-dimensional array containing the y values.

bullet.gif    sLabelX is an optional label for the x axis.

bullet.gif    sLabelY is an optional label for the y axis.

bullet.gif    sCaption is an optional plot caption.

bullet.gif    sWindowTitle is an optional plot window title.

bullet.gif    Parameters that are nil or missing to the right adopt default values.

Return values:

bullet.gif    CPlotView is returned as a new CPlotView object attached to the plot window. It is nil on failure.

bullet.gif    CPlot is returned as a new CPlot object attached to the current plot series. It is nil on failure.

Remarks

This function creates a quick plot using just one line of code. The returned values of V and P provide access to the plot window and plotted data. You can also change the plot properties including the marker attributes, labels, scaling, and others using commands such as Series Attributes and Plot Attributes.

Only the first 2 arguments, the (x,y) data, are required. If you want to use the other arguments, you must include a nil placeholder to fill any holes between the arguments.

Examples

The script below creates some data from the random number generator and creates a stepped line plot with default plot labels. Since none of the optional parameters is used, only the x and y arrays need to be specified.

x = random( 10, 10, 20 )

-- 10 values between 10 and 20

y = random( 10, 20, 40 )

-- 10 values between 20 and 40

stepline( x, y )

-- create the stepped line plot

Related Topics

steplineerr, plot, scatter, line, connect, CPlotView class, Plotting Functions, Comparison of non-Class Plotting Functions


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.