LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Minimum on Plots

Hi:

I am looking to be able to get the minimum value on a plot of data without have to zoom in and use a snap to point cursor.  Is there a LabWindows function that I might be able to utilize or something similiar?  Thanks for any and all help.

 
0 Kudos
Message 1 of 7
(3,904 Views)
I don't see anything directly, but you could use the GetPlotAttribute () function to retrieve  ATTR_PLOT_YDATA into a buffer and then use the analysis library function MaxMin1D () to get the minimum value in the buffer.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 2 of 7
(3,900 Views)
Thanks for your suggestions, but I've looked into the ATT_PLOT_YDATA into a buffer but I believe that that can't be used for a PlotPoint style of graph.  I should mention that I am trying to find the minimum coordinates without user interaction (i.e zooming and panning).  Thanks.
0 Kudos
Message 3 of 7
(3,901 Views)
So you are using the PlotPoint() function to plot a bunch of points on a graph?
 
I see two options really and they both require a bit more work than I suggested in my first rpely before I knew that.
 
The first is to keep track of the coordinates of each point you are plotting as it is plotted. You can then find the minimum from that data.
 
The other approach is to use the PlotXY function with the X an Y data "arrays" consisting of 1 value each. If you use this approach, you can use the GetPlotAttribute function to get the ATTR_PLOT_YDATA for each of the individual plots but to do so, you will need to keep track of the plot handles.
 
With either approach, I would use the List functions in the Programmer's Toolbox library to keep track of the data. In the first approach, I would create a structure to save the plot handle, X value and Y value for each point. The second approach is simpler in that you don't have to store the plot data (the control does that for you), you only have to keep track of the plot handles which are just integer values. Using the List functions let's you do all of this dynamically, you can add and delete points and access the data anytime with no user intervention at all.
 
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 4 of 7
(3,887 Views)
If you set your graph axes to autoscale, autoprecision, with loose fit turned off, the maximum and minimum x- and y-values can be read directly off the axes by the user, or obtained programmatically by calling GetAxisScalingMode(). This should do the trick if the value is all you require; otherwise, you could use the List functions as suggested by Martin. Personally, I would use a single PlotXY() call with scattered points rather than PlotPoint(), and regenerate the x and y arrays each time the list is modified.

Regards,
Colin.

0 Kudos
Message 5 of 7
(3,875 Views)
Thanks for all your suggestions.   I tried using the GetAxisScalingMode but I was I unsuccessful in attaining the coordinates of the global minimum...does it appear that my only option is try and use PlotXY() to obtain the coordinate that I looking for? 

Thanks,
Brett
0 Kudos
Message 6 of 7
(3,849 Views)

It should work, provided you RefreshGraph between autoscaling and retrieving axis range:

 // Obtain original Y-axis scaling
 GetAxisScalingMode (panel, PANEL_GRAPH, VAL_LEFT_YAXIS, NULL, &ymin, &ymax);

 // Set graph to auto-scale and retrieve axis range
 err = SetAxisScalingMode (panel, PANEL_GRAPH, VAL_LEFT_YAXIS, VAL_AUTOSCALE, 0, 0);
 RefreshGraph (panel, PANEL_GRAPH);
 GetAxisScalingMode (panel, PANEL_GRAPH, VAL_LEFT_YAXIS, NULL, &min, &max);

 // Restore original axis scaling
 SetAxisScalingMode (panel, PANEL_GRAPH, VAL_LEFT_YAXIS, VAL_MANUAL, ymin, ymax);
 SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_VISIBLE, 1);

 sprintf (msg, "Minimum and maximum are %.2f and %.2f.", min, max);
 MessagePopup ("Values", msg);

This way the graph will flicker a little when autoscaling, but I found no way of avoiding it: hiding the graph before these lines and displaying it does prevents the graph to autoscale.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 7
(3,833 Views)