CPlotView:PlotPoints


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

Syntax

CPlot = CPlotView:PlotPoints()

CPlot = CPlotView:PlotPoints( sX )

CPlot = CPlotView:PlotPoints( sX, sY )

CPlot = CPlotView:PlotPoints( sX, sY, sTitle )

CPlot = CPlotView:PlotPoints( sX, sY, sTitle, sCaption )

bullet.gif    sX is the optional x axis label. If nil, a default is used.

bullet.gif    sY is the optional y axis label. If nil, a default is used.

bullet.gif    sTitle is the optional window title. If nil, a default is used.

bullet.gif    sCaption is the optional plot caption. If nil, a default is used.

Return value:

bullet.gif    CPlot is a new CPlot object attached to the current plot series. It is nil on failure.

Remarks

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 plot below was generated using the second script in the Examples, below. 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.

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 = new_plotview()

-- 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 = new_plotview()

 

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 class, PlotMatrix, PlotDataLine, AddPoints, PlotLine

 


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