CPlotView:PlotMatrix CPlotView:AddMatrixRange

CPlotView:PlotMatrixRange


The PlotMatrixRange method plots data stored in one or more rows of a CMatrix. This method uses an external matrix, not the class data matrix. The data are plotted as symbols. Each row creates a different plot series.

Syntax

bSuccess = CPlotView:PlotMatrixRange( CMatrix, y1, y2, sX, sY, sTitle, sCaption )

    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.

    sX is the optional x axis label. If omitted or nil, a default is used.

    sY is the optional y axis label. If omitted or nil, a default is used.

    sTitle is the optional window title. If omitted or nil, a default is used.

    sCaption is the optional plot caption. If omitted or nil, a default is used.

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

    On failure false is returned.

 

Line Plot window using default x label, y label, title, and caption. The caption above the plot box shows that data in columns 22 42 and rows 12 through 14 were plotted. The 3 rows were plotted in 3 series using different colors (black, red, green). There were no points in row 14.

Remarks

This method make a symbol plot from a range of rows in a CMatrix. Alternatively, you can make the same type of plot, but with connected lines rather than symbols, using the PlotMatrixRangeLine method. In comparison, the PlotMatrixLine and PlotMatrix methods plot all rows of the matrix, rather than a range of rows.

The plotted data come from a sparse CMatrix. The matrix contains values at (column,row) indices. The matrix rows are not required to have the same beginning and ending columns. Every row does not have to exist in the plotted range, nor does every column need a value. Holes are automatically set to 0. For example, the picture above shows a plot made from 4 points existing in the first row of a small matrix (see the example, below).

Example

The plot window above shows 3 data points plotted with only 1 point in each of the 3 series. These points were plotted from rows 12, 13, and 14 in a matrix containing 8 points in the rectangle [22:42, 11:16] (note: this is [column:column, row:row notation]). Points in rows 11, 15, and 16 were ignored and no point exists in row 14, which lies in range. The x-axis scaling extends from column 22 through 38 because that is the region covered by the matrix. The data and plot were generated by the following script:

A = CMatrix:new()

-- create a new CMatrix

A:Set( 16, 22, 1)

-- add a point at y=16, x=22, value= 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 = CPlotView:new()

-- create a new CPlotView

P:PlotMatrixRange( A, 12, 14)

-- create the line plot

Related Topics

CPlotView, PlotMatrixRangeLine, PlotMatrix, CMatrix