CPlotView:AddSeries CPlotView:PlotMatrixRange

CPlotView:PlotMatrix


The PlotMatrix method plots all of the rows of a CMatrix using symbols. Each row of the matrix is plotted as a different plot series.

Syntax

bSuccess = CPlotView:PlotMatrix( CMatrix, sX, sY, sTitle, sCaption )

    CMatrix is a matrix holding the data to plot.

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

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

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

    sCaption is the 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 using default labels for x axis, y axis, title, and caption. The CMatrix contains one line, which is row 11. The caption above the plot box shows that columns 22 through 38 were plotted from row 11 through 14. The 3 series are shown in different colors and are over-plotted in this view.

Remarks

This method plots all of the rows of a sparse matrix stored in a CMatrix. The sparse matrix is filled with members that consist of a row and column index and a value. The fact that the CMatrix is sparse means that every cell does not have to be populated. In other words, indices do not need to exist between 1 and the minimum column or between 1 and the minimum row. Similarly, the matrix may have "holes" between minimum column and maximum column. Holes are filled with 0's, which can be seen in the sparse data array plotted in window shown above.

To plot the same data as connected lines rather than as discrete symbols, use the PlotMatrixLine method. To plot a range of rows or a single row, use the PlotMatrixRange method.

Example

The plot window above shows 4 data points having y=11 in the range x=22 to x=42. The data and plot were generated by the following script. Note: we equate "x" to column index and "y" to row index.

A = CMatrix:new()

-- create a new CMatrix

A:Set(11,24,10)

-- add a point at y=11, x=24, value= 10

  ... add more ...

-- add more points and other rows

P = CPlotView:new()

-- create a new CPlotView

P:PlotMatrix(A)

-- create the symbol plot

Related Topics

CPlotView, PlotMatrixRange, PlotMatrixLine, CMatrix