CPlot:FindNearestY


The FindNearestY method returns the index in a plot series of the point with y value nearest a target value.

Syntax

nIndex, y = CPlot:FindNearestY()

bullet.gif    nIndex is the index of the plot series, from 1 to CPlot:Count.

bullet.gif    y is the y value of the point.

bullet.gif    On failure, 0,0 is returned.

Example

The following script finds the index of the point with y value nearest 133.6 in series 1 of a CPlotView on the Mira desktop:

V = attachlist_plotview()

-- select the target plot window

if V == nil then Exit() end

-- if not successful, exit the script

P = V:GetPlot(1)

-- get a CPlot object for series 1

if P == nil then Exit("Bad series") end

 

nTargY = 133.6

-- find the point nearest y=133.6

n, y = P:FindNearestY( nTargY )

-- get index n and value y

Printf("Near y=%lg: y[%d]=%lg\n", nTargY, n, y)

-- print the results

Related Topics

CPlotView class, CPlot class, FindNearestX


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