Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

how to plot mulitple graph in scattergraph control?

Solved!
Go to solution

Hi,

 

I have two double arrays declared and I like to plot x and y and x and x. I can do one at a time, how can I append it so that both x,y and x,x points are displayed. I tried using the plotXYmulitple command, but it requires 2D array. Do I have to convert  my data into 2D array or there is an easier option? any help would be greatly appreciated.

0 Kudos
Message 1 of 15
(6,434 Views)

Hello, Yes you will have to pass it a 2D array so your will need to create that out of your 1D array

National Instruments
0 Kudos
Message 2 of 15
(6,415 Views)

Thanks Anna.

 

I tried that and here is the problem:

 

There is mismatch between PlotXYMultiple function in documentation and actual implementation. see below for the picture. You think it might be a possible bug? it seem xData and yData is swaped.

 

24142i9F662655F2E4FAE5

 

public void PlotXYMultiple(
double[] xData,
double[,] yData
}
0 Kudos
Message 3 of 15
(6,360 Views)

That looks like a bug to me. I have submitted this to our developpers to repair. Thank you for briniging this to our attention.

National Instruments
0 Kudos
Message 4 of 15
(6,323 Views)

Hello, my apologies, upon closer inspection I see that you are using PlotYXMultiple to demonstrate the tip strip but quoting PlotXYMultiple in the Help. Problem solved!

National Instruments
Message 5 of 15
(6,310 Views)
Solution
Accepted by Shazaduh

You are absolutely right! thats what happen you are coding two in the morning. I am posting my own solution below in case anyone else interested. But you know it will be nice if you can do mulitple ploting like matlab function plot(x,y,x,y) etc.

 

Thanks again!

Kashif

 

 

            double[] xValues = new double[5] { 1, 2, 3, 4, 5 };
double[] y1Values = new double[5] { 1, 2, 3, 4, 5 };
double[] y2Values = new double[5] { 1, 4, 9, 16, 25 };



scatterGraph1.DefaultDataOrientation = DataOrientation.DataInColumns;

double[,] yValues = new double[xValues.Length, 2];

for (int i = 0; i < xValues.Length; i++)
{
yValues[i, 0] = y1Values[i];
yValues[i, 1] = y2Values[i];
}

scatterGraph1.PlotXYMultiple(xValues,yValues);

 

 

0 Kudos
Message 6 of 15
(6,302 Views)

I would like to plot two sets of data points (X1, Y1) & (X2, Y2) on the scatter graph as soon as I receive them, psuedo real time plot.  Below is the data I'm trying to plot.  However the data doesn't look right.  What do I need to do, so my two points are appended to their last points? 

 

 

do  

' read data to get Data1 & Data2

x1 = runLength.TotalMinutes

x2 = runLength.TotalMinutes

 

y1 = Data1(index)

 

y2 = Data2(index) 

 

 

frmInfo.ScatterGraph1.PlotXYAppend(xVal, yVal)

 loop while (flag)

 

 

Graph.JPG

0 Kudos
Message 7 of 15
(5,842 Views)

correction in my last code

 

 

do  

' read data to get Data1 & Data2

 

x(0) = runLength.TotalMinutes

x(1) = runLength.TotalMinutes

y(0) = Data1(index)

y(1) = Data2(index) 

 

 frmInfo.ScatterGraph1.PlotXYAppend(x, y)

 

 loop while (flag)

0 Kudos
Message 8 of 15
(5,841 Views)

Could you please be just a little more specific on what you mean by

 

"so my two points are appended to their last points"

 

What exactly should be appended to what?  Or what do you expect the plot to look like?

Jensen
National Instruments
Applications Engineer
0 Kudos
Message 9 of 15
(5,818 Views)

What I'm looking for is a way to have two streams of data.  One would be plotted on the primary Y axis, and the other would be plotted on the secondary Y axis.  The data would be plotted onto the graph when it's received (so appending it to the graph).  Attached is an example of what I'm looking for. (done in excel)

 

graph.JPG

0 Kudos
Message 10 of 15
(5,814 Views)