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. This method is a generic drawing function which combines the MoveTo, LineTo, Marker, and LineToMarker methods.
nIndex = CPlotView:Add( CPolygon ) nIndex = CPlotView:Add( CPolygon, nDrawMode ) nIndex = CPlotView:Add( x, y ) nIndex = CPlotView:Add( x, y, yErr ) nIndex = CPlotView:Add( x, y, xErr, yErr ) nIndex = CPlotView:Add( x, y, xErr, yErr, nDrawMode ) where |
CPolygon is a CPolygon object that describes the marker.
x, y are the x and y coordinates of the point.
xErr is an optional value of the x error bar (or the y error bar; see below)
yErr is an optional value for a y error bar.
nDrawMode is an optional argument that describes how to interpret this point.
nIndex is the index at which this point was added. On success, this method returns nIndex > 0, on failure it returns 0.
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 formats:
Add a marker at x,y using a polygon marker: Add( CPolygon )
Add a marker, or draw a line to a marker at x,y using a polygon: Add( xCPolygon, nDrawMode )
Add an x,y pair using Add( x, y )
Add an x,y pair with a y error bar using Add( x, y, ye )
Add an x,y pair with both x- and y- error bars using Add( x, y, xe, ye )
To add only an x error bar, use Add( x, y, xe, 0 ).
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.
The drawing mode determines whether the point becomes a marker, a line, a line with a marker, or an invisible move. By combining the 4 drawing modes,any combination of moving and drawing, markers, and lines can be combined in the same plot series.
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. |
The following script adds points and draws them in a CPlotView. The drawing mode (5th argument) is not used.
|
-- create a CPlotView, but not a window |
|
-- add a point |
|
-- add a point with a y error bar, get index |
|
-- result: index = 2 |
|
-- add a point with x and y error bars |
-- |
-- add 97 more points |
|
-- plot in a new window (use () for default labels) |
|
-- the number of points in the series |
|
-- result: n = 100 |