From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PlotXY manual X Axis Scaling doesn't rescale Y-Axis auto-scaling


I'm using PlotXY(..) to display data on a graph.

I use SetAxisScalingMode(...) to set set VAL_LEFT_YAXIS to VAL_AUTOSCALE.  

I use SetAxisScalingMode(...) to set set VAL_TOP_XAXIS scaling to VAL_MANUAL.

 

I make various calls to SetAxisScalingMode(...) which change the min & max values for the X-Axis.

Everything thing seems to display correctly except that changing min & max values using manual scaling on the x-axis does not seem to change the range of data used to auto-scale the y-axis.

 

For example say you have a peak in your data that you want to exclude so the auto-scaling on the y-axis will zoom in.
So you change the max, min manual x-axis scaling to leave out the peak but scaling but the y-axis scaling doesn't change.

 

Is this the way it should work?

Ideas for a work around?

 

Thanks,
Kirk

0 Kudos
Message 1 of 10
(9,199 Views)

I can't tell if this is the way it should work...

 

But you can try the following to cause a recalculated autoscaling: set the scaling to VAL_LOCK and then change it back to VAL_AUTOSCALE

 

This is what I have learned from NI here

0 Kudos
Message 2 of 10
(9,179 Views)

Wolfgang,

 

I'm quite sure my code is causing the plot recalculate the auto-scaling.

 

Maybe this will help explaing what I mean:

 

I modified the example graphs.prj that comes with LabWindows/CVI to demonstrate this.

 

Run the example and click on the the Plot Line button.

Observe that it autoscales the Y axis to 200.0 even though the data point containing 200.0 is not on the plot.

 

For details look in the function: int CVICALLBACK PlotData(...)

 

Kirk

 

 

 

 

 

0 Kudos
Message 3 of 10
(9,161 Views)

I'm sorry, I tried your example but did not find a possibility to resolve the issue...

0 Kudos
Message 4 of 10
(9,152 Views)

OK, Thanks for giving it a try.

 

I guess that's the "normal" behavior for the manual scaling. 

Maybe someone else will have some ideas.

 

Possibly instead of using manual scaling to restrict the range of the x-axis I'll re-plot plot with a different range of x values.

 

 

 

0 Kudos
Message 5 of 10
(9,138 Views)

Hi Kirk,

 

As you've noticed, the autoscaling of an axis in the graph is based on the entire data of each plot, not just on the portion of the plot that is within the range of the other axis.

 

If you use only integer limits for the min and max of the x axis, if you plot only 1D arrays, and if you don't mind re-plotting every time that you want to manually change the x-axis, there's a possible workaround, consisting of replacing PlotY with PlotWaveform, so that you can offset the data to plot.

 

I've adapted the code that you attached earlier to illustrate this:

 

int xmin = 40;
int xmax = 90;
SetAxisScalingMode(handle, PANEL_GRAPH, VAL_BOTTOM_XAXIS, VAL_MANUAL, (double)xmin, (double)xmax);
PlotWaveform (handle, PANEL_GRAPH, datapoints + xmin, xmax - xmin, VAL_DOUBLE, 1.0, 0.0, xmin, 1.0,
              style, VAL_EMPTY_SQUARE, VAL_SOLID, 1, color);

 

0 Kudos
Message 6 of 10
(9,105 Views)

Hi Luis,

 

would it be possible to add this information to the help? At present it doesn't waste any word on it...

 

And do you think there are chances that the current behavior could be improved (after filing an idea suggestion, of course)? I think the more natural behavior would be to have autoscaling to the visible data, and now I recall that some time ago I had to implement this sort of autoscaling myself: go through all plots, find their maxima and minima,...

0 Kudos
Message 7 of 10
(9,091 Views)

I agree.  It would be nice to see it improved.

For now I think I'll look into modifying my code to change the range of data that is plotted when the manual scaling is activated.

Thanks again for the insight!

 

0 Kudos
Message 8 of 10
(9,076 Views)

Fair enough. We'll update the documentation.

 

Yes, it's reasonable to request that this be improved. But, to clarify, "improvement" cannot mean changing the current auto-scaling behavior, since this would break existing programs -- the new behavior would have to be introduced via a different axis setting, which would not be on by default.

Message 9 of 10
(9,065 Views)

Thank you Luis.

 

The suggestion can be found here

0 Kudos
Message 10 of 10
(9,053 Views)