Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scattergraph Y-Axis autoscale from 0 to n

Hello, I have an scattergraph and want to draw an spectrum. All works fine for me but the plot should autoscale the y-Axis from 0 to n (n is the calculated maximum on y-axis) thats the maximum what the scattergraphes scale. 

 

The following picture shows an example and there is no point which is on the coordinate x.axis. And so the scattergraphs scales from

the lowest point to the highest one on the y-axis. What i have to do to scale from 0 to n?

 

I had 2 Ideas, the first one is to plot 1 Point on 0,0 and the second one is to go in the yRangeChanged Event and set the Range from 0 to the maxvalue.

But i belive the second one is an expensiv operation and so i would prefer the first idea. But maybe is there an automatic mechanism to get the scale result what i want.

 

 

0 Kudos
Message 1 of 3
(4,463 Views)

private: System::Void scatterGraph_YAxisRangeChanged(System::Object^ sender, NationalInstruments::UI::YAxisEventArgs^ e) { double min = this->yAxis_scatter->Range->Minimum; double max = this->yAxis_scatter->Range->Maximum; if(min > 0) min = 0.0; this->yAxis_scatter->Range = gcnew NationalInstruments::UI::Range(min, max); }

 

This is my solution...
0 Kudos
Message 2 of 3
(4,418 Views)

Hi Jeschki,

 

As you already know, if the autoscaling is used, the axis will scale from minimum plotted value to the maximum plotted value.

 

Your requirement is that only the maximum of the range to change with the plotting. Looking at the picture attached and your requirement it seems that the data that is always greater than zero.

 

If so, you could trick the autoscaling by using a value of zero in your data array as the lowest value. With the autoscaling on, you already know that the lowest value is zero in the data. But this value should not be visible in the graph's plot area. The X-Axis uses the range of (400,700). So make sure that the data value zero is appended either at 399 or 701. 

 

This is a tweaky solution.  Hope this helps.

0 Kudos
Message 3 of 3
(4,336 Views)