CPlotView:AddMatrixRange


The AddMatrixRange 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 symbols. Each matrix row creates a different plot series.

Syntax

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

    CMatrix is a matrix holding the data to plot.

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

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

    bSuccess is the returned success code. On success it is true, otherwise false.

 

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

Result of using the present AddMatrixRange 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 AddMatrixRangeLine.

  

This method adds data stored in a CMatrix to an existing Plot Window. The new data are plotted as point symbols and each matrix row creates a new series with its unique symbol 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 PlotMatrixRangeLine 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 included in the sample file "Plot Matrix Test.Lua". 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 = CPlotView:new()

-- create a new CPlotView object

A = CMatrix:new()

-- 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 stepline

 

 

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:AddMatrixRange( A, 12, 14 )

-- add CMatrix rows as new series

 

 

A:delete()

 

P:delete()

 

Related Topics

PlotMatrixRange

PlotMatrix

CPlotView class

CMatrix class