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- error bars. See the remarks section to understand the different syntax used for each case.

Syntax

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

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

bullet.gif    xErr is an optional value of the x error bar (or the y error bar; see Remarks)

bullet.gif    yErr is an optional value for a y error bar.

bullet.gif    nDrawMode is an optional argument that describes how to interpret this point (see Remarks).

bullet.gif    nIndex is the index at which this point was added. On success, this method returns nIndex > 0, on failure it 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 plot data.

This method has several forms:

bullet.gif    Add an x,y pair using Add( x, y )

bullet.gif    Add an x,y pair with a y error bar using Add( x, y, ye )

bullet.gif    Add an x,y pair with both x- and y- error bars using Add( x, y, xe, ye )

bullet.gif    To add only an x error bar, use Add( x, y, xe, 0 ).

bullet.gif    To use drawing mode, specify all 5 parameters. If no error bars are desired, set xe and/or ye to 0. The drawing mode, nDrawMode, is described below.

The error bar is specified as 1/2 of the total error bar length so that the specified length is drawn on each side of the point. For example, specifying the standard deviation, sigma, causes an error bar 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.

Using the Drawing Mode

The drawing mode controls whether the point becomes a marker, a line, or is a move with no drawing. By combining the 4 drawing modes,any combination of moving and drawing, markers, and lines can be combined in the same plot series. The drawing mode is available only if you specify values for the first 4 arguments. If the point has no error bars, just specify 0 for their lengths.

Drawing Modes

nDrawMode

Operation

0

Draws a marker at x,y

1

Moves to x,y (draws nothing).

2

Draws a line to x,y starting from the prior point.

3

Draws a marker at x,y and draws a line to x,y starting from the prior point.

Example

The following script adds points and draws them in a CPlotView. The drawing mode (5th argument) is not used.

 

V = new_plotview()

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


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