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.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make Y Axis shrink during autoscale

 
I'm plotting some data on a waveform graph in stripchart mode.
The data is sampled once a second and can vary greatly over the measurement period.
I'm using PlotYAppend(double, timespan) to plot the data and have a fixed X Axis range of 1 minute.
My chart historycapacity is set to 65 i.e. just enough to fill the chart.
 
My problem is that if the Y Axis grows under auto scale it never shrinks back down. So say my ambient measurement hovers around 2 units for the majority of the time but I can expect a spike at 50 units. When the 50 unit measurements is charted the auto scale jumps the maximum Y value to around 60 but leaves the minimum down at 0 then if the data returns to its ambient 2 units the chart is worthless because all the detail is lost.
 
Can anyone help me to force the Y scale to shink back once the spike has cleared off the strip chart?
 
Thanks,
 
Mike
0 Kudos
Message 1 of 9
(4,265 Views)

Maybe I need to manually scale the y axis? I was hoping I wouldn't have to...

Can anyone help, please?

0 Kudos
Message 2 of 9
(4,237 Views)
You can scale the graph y-axis manually once the spike is gone.
 
One way to do this would be to use the plot history and  scale the axes according to the min/max data currently displayed.
 
 
After you PlotYAppend the data, use the following snippet to find the min and max data in the plot and scale the y-axis

ArrayOperation.MaxMin1D(waveformPlot1.GetYData(), out max, out min);

if (max == min)

return;

yAxis1.Range =

new Range(min, max);

 

Hope this helps.

Bilal Durrani
NI
0 Kudos
Message 3 of 9
(4,229 Views)
You can try setting Mode property of the YAxis to AutoScaleExact.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 4 of 9
(4,226 Views)

Thanks guys,

 

I've tried AutoScaleExact and AutoScaleLoose but neither option lets the scale shrink. Smiley Sad

 

I've implemented some manual scaling very simlar to the snippet provided by Bilal. I've increased my historycapacity setting slightly so that the Y scale doesn't start to shrink immediately after th peak disapears.

 

The only other possibility I can think of is extacting the data history from the plot, clearing the plot completly and then redrawing the chart with just the current 60 seconds worth of data and see how the Y scale behaves then!

 

Mike

0 Kudos
Message 5 of 9
(4,223 Views)
We have verified that this is in fact a bug in the way the axis updates its Range. The problem has been fixed and will be available in the next version of Measurement Studio.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 6 of 9
(3,987 Views)
Excellent, thanks for letting me know.
 
Have you any idea of a date at all?
 
Mike
0 Kudos
Message 7 of 9
(3,985 Views)
Unfortunately, we are not at the liberty to discuss specific release dates for unannounced products, but I can tell you this - it will be available very soon.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 8 of 9
(3,981 Views)

Smiley Wink

 

0 Kudos
Message 9 of 9
(3,977 Views)