Retrieving Coordinates from Axis Wave on a Graph

Hi,

I know that hcsr and vcsr returns the x and y coordinates of a cursor, while CsrInfo, pcsr, and xcsr can be used to obtain the point number. If I am plotting Y_Axis_Wave against X_Axis_Wave and I would like to retrieve the x coordinate of an arbitrary value on X_Axis_Wave, how would I go about it (without using a cursor since there may not be a point at that value)?

For example,
X_Axis_Wave = {0, 1, 2, 3, 4}
Y_Axis_Wave = {4, 11, 3, 7, 1}
If I want the x coordinate at X_Axis_Wave[Index] = 1, I can select that point with the cursor and get the x coordinate with hcsr.
If I instead want the x coordinate at X_Axis_Wave[Index] = 1.5, there will be no point to select with a cursor, and the above method no longer works.
Try either the FindLevel or BinarySearch commands on the X wave.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Sorry, I just realized that the x coordinate given by hcsr is that of the datapoint, not of the graph xy offset, so that the example above is trivial. The x coordinate at X_Axis_Wave[Index] = 1 would be 1, and the x coordinate at X_Axis_Wave[Index] = 1.5 would be 1.5. What I actually wanted to find was the XY offset given the x coordinate so that I can create textboxes set apart proportionally to the x coordinates.

So I have a wave of x values (positive to negative) and a wave containing medians of ranges of those x values. I want to place a textbox between the average of each pair of median values. XY offset is the method textboxes are placed rather than the x coordinates, and XY offset range of interest varies from 0 to 100, meaning I would have to standardize the x coordinate values (from say -5 to 5) on the scale of 0 to 100. I have the textboxes using top left (LT) anchor. I was hoping there was a direct way to convert from x coordinate to X offset, but currently I have:

waveStats X_Wave
Range = V_max - V_min
AverageMedian = abs(V_min) + (Median_Wave[x] + Median_Wave[x-1])/2
Position_X = -3 + 100*(AverageMedian)/Range // -3 needed to adjust the textbox location

Is there a better way to do this? And if not, is the logic applied properly here?
What you are calling the "X offset" or "X coordinate" is, I believe, actually the window-relative pixel location.

To figure out where in pixel coordinates a particular axis-relative X or Y value is plotted, you can use the PixelFromAxisVal function:

PixelFromAxisVal(graphNameStr, axNameStr, val )
The PixelFromAxisVal function returns the local graph pixel coordinate corresponding to the axis value in the graph window or subwindow.


Then use GetWindow psize to get the plot area extent

To calculate the needed TextBox/X= and /Y= offsets, you'll need both the window size, plot area size and perhaps the graph margins. See GetWindow psize, GetWindow wsize. You might also need the AxisValFromPixel function to do other calculations.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.