CPlotView:Remove CPlotView:AddPoints

CPlotView:PlotPoints


The PlotPoints method draws points from the class data matrix in a new plot window. This method can plot markers, lines, and errob bars for both axes. The illustration below shows only (x,y) pairs without errorbars.

Syntax

bSuccess = CPlotView:PlotPoints( sX=nil, sY=nil, sTitle=nil, sCaption=nil )

Sample Plots

The first plot below shows a simple scatter plot without error bars. This plot was generated using the first sample script in the Examples, below. The legend was turned off

The plot below was generated using the second script in the Examples..

Remarks

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

This method plots all points in the class data matrix as a single series in a plot window. Data points are drawn as symbols as shown above.

Example

The script below created the plot window shown above. Although this example shows simple (x,y) points, y errorbars or x,y errorbars could have been plotted by adding them their extra arguments in the Add method.

V = CPlotView:new()

-- create a new CPlotView

V:Add( 5.52, 100.5)

-- add point 1: x=5.62, y=100.5

V:Add( 6.52, 80.5)

-- add other points

V:Add( 8.52, 90.5)

 

V:Add( 2.52, 110.5)

 

V:Add( 15.12, 94.5)

 

V:Add( 8.22, 60.5)

 

V:Add( 11.82, 70.5)

 

V:Add( 4.62, 90.5)

 

-- make the plot

 

V:PlotPoints( "Position", "Value", "Scatter Plot", "Defined 8 points")

 

The next example is far more sophisticated but only a little more complicated. This example uses all 5 arguments for the Add method, which includes the draw mode for each point (e.g., move to, line to, marker, etc.). The script adds points into 2 data series and displays them simultaneously in "over plot" mode. Error bars are included in the first series. This script generated the plot shown above.

P = CPlotView:new()

 

P:Add( .0045, 60.5, 0.00012, 5, 0 )

-- add marker (with error bars)

P:Add( .0067, 80.65, 0, 0, 2 )

-- line to point

P:Add( .0085, 90.5, 0, 0, 2 )

-- line to point

P:Add( .0092, 110.12, 0.0002, 3.4, 2 )

-- line to [pomt with error bars

P:Add( .0105, 112.2, 0.00012, 5, 0 )

-- add marker with error bars

P:Add( .0113, 117.5, 0, 0, 3 )

-- line to marker

P:Add( .012, 127.1, 0, 1.8, 0 )

-- add marker with error bar

P:Add( .0142, 130.4, 0.0002, 3.4, 2 )

-- line to point with error bars

 

-- Display the points in a new plot window

P:PlotPoints( "Distance (mm)", "Signal", "Sample plot", "Experimental results" )

 

-- define another group of points (not ordered by increasing x value)

P:Empty()

-- emove data points already defined

P:Add( .0162, 90.5, 0, 0, 3 )

-- add all points as "LineToMarker"

P:Add( .0135, 85.5, 0, 0, 3 )

 

P:Add( .0152, 92.5, 0, 0, 3 )

 

P:Add( .0215, 101, 0, 0, 3 )

 

P:Add( .0167, 96.5, 0, 0, 3)

 

P:Add( .0172, 81.25, 0, 0, 3 )

 

P:AddSeries("6 more points" )

-- add these 6 points as a new series

 

 

P:SetLegendStyle(1)

-- add legend at bottom

P:SetSeriesMode(4)

-- change to "overplot" mode.

Related Topics

CPlotView, PlotMatrix, PlotDataLine, AddPoints