AddMatrixRangeLine


The AddMatrixRangeLine method adds data from a range of rows in a CMatrix as new series in the Mira Plot Window attached to the class. This method uses an external matrix, not the class data matrix. The data are plotted as line plots. Each matrix row creates a different plot series.

Syntax

bSuccess = CPlotView:AddMatrixRangeLine( CMatrix, y1, y2 )

bullet.gif    CMatrix is a matrix holding the data to plot.

bullet.gif    y1 is the minimum row number to plot, beginning at row 1.

bullet.gif    y2 is the maximum row number to plot, beginning at row 1.

bullet.gif    On success, the method creates a plot window and returns true.

bullet.gif    On failure false is returned.

Plot created using the PlotMatrixLine method and the top portion of the script example listed below.

Result of using the present AddMatrixRangeLine method to add data series to the plot shown above. This was done using the lower portion of the script example listed below.

The plot window automatically re-scaled to accommodate the new data.

Compare with the lower picture in AddMatrixRange.

Remarks

This method adds data stored in a CMatrix to an existing Plot Window. The new data are plotted as stepped lines and each matrix row creates a new series with its unique line attributes. This method adds the CMatrix point at ( row, col, value ) to the existing plot as ( series, x, y ). Each matrix row defines a different series.

The data added to the plot are specified by the range of CMatrix rows passed as parameters. Not every row within this range must exist in the matrix. For example, if you specify y1=10 and y2=100 and the matrix has data in every row, then 91 rows of data are added to the plot. Alternatively, if there are data only in matrix rows 10, 20, and 50, then y1=10 and y2=100 adds only 3 rows of data to the plot. Alternatively, you can make the same type of plot, but with connected lines rather than symbols, using the PlotMatrixRange method. PlotMatrix methods plot all rows of the matrix, rather than a range of rows.

Example

The plot windows shown above were created using the following script, which is modified slightly from the script included in the sample file "Plot Matrix Test.lua". In the sample file, the call to AddMatrixRange was changed to AddMatrixRangeLine to produce the script below.

First, a CMatrix is filled with points and plotted as a lineplot using PlotMatrixLine to produce the upper plot of the two shown above. Then the matrix was emptied, 5 new points were defined, and the present method was called to add them to the plot, which produced the lower window shown above.

 

P = new_plotview()

-- create a new CPlotView object

A = new_matrix()

-- create a CMatrix and add points

A:Set( 16, 22, 1 )

 

A:Set( 11, 24, 10 )

 

A:Set( 12, 25, 1 )

 

A:Set( 13, 27, 6 )

 

A:Set( 11, 22, 12 )

 

A:Set( 13, 38, 4 )

 

A:Set( 12, 28, 19 )

 

A:Set( 11, 25, 15 )

 

P:PlotMatrixLine( A )

-- plot the matrix as a steplines

 

 

A:Empty()

-- clean out the CMatrix

A:Set( 12, 22, 5.8 )

-- add point at row 12, column 22

A:Set( 12, 16, 17.5 )

-- add point at row 12, column 16

A:Set( 13, 22, 15.8 )

-- add point at row 13, column 22

A:Set( 14, 18, 15.1 )

-- add point at row 12, column 22

A:Set( 14, 17, 27.35 )

-- add point at row 12, column 16

P:AddMatrixRangeLine( A, 12, 14 )

-- add CMatrix rows as new series

 

 

A:delete()

 

P:delete()

 

Related Topics

CPlotView class, PlotMatrixRangeLine, PlotMatrix, CMatrix


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