CPlot:FindNearestX


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

Syntax

nIndex, x = CPlot:FindNearestX()

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

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

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

Example

The following script finds the index of the point with x value nearest 4.2 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

 

nTargX = 4.2

-- find the point nearest x=4.2

n, x = P:FindNearestX( nTargX )

-- get index n and value x

Printf("Near x=%lg: x[%d]=%lg\n", nTargX, n, x)

-- print the results

Related Topics

CPlotView class, CPlot class, FindNearestY


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