Retrieving Coordinates from Axis Wave on a Graph
Ken
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.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 11, 2011 at 10:19 pm - Permalink
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?
June 14, 2011 at 06:58 am - Permalink
To figure out where in pixel coordinates a particular axis-relative X or Y value is plotted, you can use the PixelFromAxisVal function:
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.
June 16, 2011 at 11:21 am - Permalink