Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set/force X-axis markings (starting point)?

I can't figure out how to set X Axis marking nubers to make it true values instead of just 0-N.

For example, I have this code to display multiple plots (using 2D array).  When it executes, my X-axis is always 0-N:

private double[,] data;
Graph.DataSource = data;

Or to display a single plot:

private double[] data;
Graph.DataSource = data;

I only know how to set the corresponding markings using the ChartCollection.Append(x, y) method but I'd like to know if it's possible to adjust X-axis when you are applying data to Graph at once as in example above.

Would be nice to be able to set the Starting point instead of default of 0.

Thank you.

0 Kudos
Message 1 of 12
(7,083 Views)

Hi kirko7,

 

This KnowledgeBase article discusses how to programmatically set the range of a control in Measurement Studio. You can use this to set the lower range of the XAxis to be your desired starting point. The following help document also provides some additional info.

 

Hope this helps!

Julia P.
0 Kudos
Message 2 of 12
(7,039 Views)

Thanks, but you are talking about setting Range, which isn't the same thing.

 

My X-axis by default is 0-250 (since I have 250 array elements that I assign to Graph.DataSource) and I want it to be 1000-1250 instead...  If I set Range(1000, 1250) then my Graph will show nothing, since it'll be out of range.

0 Kudos
Message 3 of 12
(7,027 Views)

kirko7,

 

A ScatterGraph has the functionality that you may be looking for. As described here, the PlotXY method allows you to plot an array of y values against an array of x values. You could then set your array of x values to be the range of numbers you want.

Julia P.
0 Kudos
Message 4 of 12
(7,006 Views)

Hi, kirko7

 

Do you simply want an offset for your data that are being plot by index, or do you want some other data to be reflected in the x-axis? Can you give us a mock up of what you aim to do?

 

Thanks!

Daniel Dorroh
National Instruments
0 Kudos
Message 5 of 12
(6,983 Views)

Hi, thanks for the reply.

I don't want to change the data itself.  I will try to explain my issue and please reference the attached screenshot.

As you can see, my X-axis starts at 0 and ends at 255.  This is because I have this code for every Graph:

 

double[,] dataArray;
// .....Populate dataArray with readings per frequency. Frequency starts at 12.0 GHz and ends at 15.0 GHz. There are 256 steps so the step size = ((15 - 12) / 256). X-axis has to correspond to steps.
Graph.DataSource = dataArray;

So the plots look good, exactly what I want and Y-axis corresponds to my readings per each frequency.  However, my X-axis have to start at 12.0 and end at 15.0 (and 256 steps of  0.01171875).  At the moment my X-axis simply corresponds to number of array elements.

Does this make more sense?

 

 

 

 

 

0 Kudos
Message 6 of 12
(6,955 Views)

The PlotXY method mentioned above will allow you to supply an x vector so you can plot your data, y, against whatever control set you want. A quick for loop will populate an array with the intended x values. You can refer to this reerence or the PlotXY method:

 

PlotXY Method (Double[], Double[])

http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/b0c66524/

 

Thanks

0 Kudos
Message 7 of 12
(6,922 Views)

Thanks, so all suggestions so far are pointing to ScatterPlot.

Will try ScatterPlot at some point this week but if anyone has a example, I would greately appreciate it.  This link doesn't have any (looking for XAML and C#)

http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/67f680cb/

 

Thank you

0 Kudos
Message 8 of 12
(6,920 Views)

I think I found an example.  Looks like I have to use array of points

0 Kudos
Message 9 of 12
(6,906 Views)

Using an array of Point values is good for arbitrary data associations. Since it sounds like your data occurs at regular intervals, you may find the new Spectrum data type better fits your scenario.

 

Another alternative would be to use a custom value presenter for the major divisions on that axis, to modify the division value before it is displayed. However, your current approach of matching the visualized data to the underlying domain is preferable.

 

(Also, it appears some of the commenters were confused about which product you were using. In the future, you may want to include "WPF" in your question title to clarify.)

~ Paul H
0 Kudos
Message 10 of 12
(6,817 Views)