scatter stepline

scattererr


The scatter function creates a scatter plot using markers for data points. This is a non-class function equivalent to the CPlotView:Scatter method. The x and y points at the same array index are presumed to correspond to the same point. The data for x, y, x error bars, and y error bars are each held in lua arrays (1-dimensional indexed tables). To plot without errorbars, use scatter.

This function creates a new plot window and returns a CPlotView object and a CPlot object for the plot and the plot series it creates. These objects can be used to enhance or add to the plot or extract plot data for further analysis. There are four similar versions of this command which are compared here.

Syntax

CPlotView, CPlot = scattererr( x, y, xe, ye )

CPlotView, CPlot = scattererr( x, y, xe, ye, sLabelX )

CPlotView, CPlot = scattererr( x, y, xe, ye, sLabelX, sLabelY )

CPlotView, CPlot = scattererr( x, y, xe, ye, sLabelX, sLabelY, sCaption )

CPlotView, CPlot = scattererr( x, y, xe, ye, sLabelX, sLabelY, sCaption, sWindowTitle )

bullet.gif    x is a 1-dimensional array containing the x values.

bullet.gif    y is a 1-dimensional array containing the x values.

bullet.gif    xe is an optional 1-dimensional array containing the x error bar values.

bullet.gif    ye is an optional 1-dimensional array containing the y error bar values.

bullet.gif    sLabelX is an optional label for the x axis.

bullet.gif    sLabelY is an optional label for the y axis.

bullet.gif    sCaption is an optional plot caption.

bullet.gif    sWindowTitle is an optional plot window title.

bullet.gif    Parameters that are nil or missing to the right are assigned default values.

Return values:

bullet.gif    CPlotView is a new CPlotView object attached to the plot window. It is nil on failure.

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

Remarks

This function creates a quick plot using just one line of code. The returned values of V and P provide access to the CPlotView window and current CPlot buffer. You can also change the plot properties including the marker attributes, labels, scaling, and others using commands such as Series Attributes and Plot Attributes.

Only the first 4 arguments, the (x,y) data, are required. Use a placeholder, like 0 or nil, to fill holes created by unused arguments. For example, to include y error bars but not x error bars, use nil in place of the xe parameter.

Examples

The script below creates a scatter plot of 1 million Gaussian Deviates including error bars on the y axis. The deviates have a standard deviation of 10 and mean of 100. A table for y errors bars is also created with a standard deviation of 3000 and mean of 0. The table for error bars is made to the same number of elements as the x-axis table x. This plot is shown above.

tbl_gauss = gaussdev(1000000, 10, 100)

-- create 1 million Gaussian deviates

H = new_histogram()

-- create a histogram object

h = H:Calc( tbl_gauss )

-- calculate the hstogram of the deviates

nCount = H:GetBinCount()

-- separate the 3 parameters for clarity

nMin = H:GetMin()+H:GetBinWidth()/2

 

nStep = H:GetBinWidth()

 

x = series( nCount, nMin, nStep )

-- create a series for the histgram x axis

ye = gaussdev( #x, 3000, 0)

-- add a table for y error bars

scattererr( x, h, nil, ye )

-- create the scatter plot with y error bars

Related Topics

scatter

plot

connect

line

stepline

CPlotView class

Plotting Functions

Comparison of non-Class Plotting Functions


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