CPlotView:GetIndex CPlotView:Count

CPlotView:Add


The Add method appends the class data matrix with a point value. The point specifies x,y coordinates and, optionally, x- and/or y-errorbars. See the remarks section to understand the different syntax used for each case.

Syntax

nIndex = CPlotView:Add( x, y, xErr, yErr )

    x,y are the x and y coordinates of the point.

    xErr is the value of the optional x-errorbar (or the y-errorbar; see Remarks). If omitted or nil, the errorbar is not drawn.

    yErr is the value of the optional y-errorbar. If omitted or nil, the errorbar is not drawn.

    nIndex is the index at which this point was added, beginning with 1.

    On success, this method returns nIndex > 0.

    On failure, this method returns 0.

Remarks

The point is appended to the end of the class data matrix. The return value gives the index of the point in the data array.

This method has several forms:

    Add an x,y pair using Add(x,y)

    Add an x,y pair with a y-errorbar using Add(x,y,ye)

    Add an x,y pair with both x- and y-errorbars using Add(x,y,xe,ye)

    To add only an x-errorbar, use Add(x,y,0,ye).

The errorbar is specified as 1/2 of the total errorbar length. For example, speicying the standard deviation. sigma. causes an errorbar to be drawn from (value+sigma) to (value-sigma).

After points are added, call PlotPoints to create a new plot window or update the existing plot window.

Example

The following script fragment adds 100 points to a CPlotView. Note that an existing CPlotView could be used for adding new points by calling Empty before Add:

 

V = CPlotView:new()

-- create a CPlotView, but not a window

V:Add(25,66.5)

-- add a point

i = V:Add(31,94.5,1.62)

-- add a point with a y error bar, get index

Printf("index = %d",i)

-- result: index = 2

V:Add(44,100.5,1.5,2.22)

-- add a point with x and y error bars

  ...

-- add 97 more points

V:PlotPoints()

-- plot in a new window (use () for default labels)

n = V:CountSeriesPoints()

-- the number of points in the series

Printf( "n=%d", n)

-- result: n = 100

Related Topics

CPlotView, Remove, PlotPoints