Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I draw two differenct plots at the same graph?

[I am beginner]

I have two different set of data which have differenct x-axis values. How can I draw two data at the same plot?

For example, one data set is
x y
1 3.5
3 2.3
5 1.3
8 3.2

The other
1 2.3
2.5 5.4
4 2.5

If I use m_graph.plotXvsY two times. But it draw only one graph at the same time.

Please let me know. Thank you in advance.
0 Kudos
Message 1 of 2
(2,993 Views)
Do you really need the two sets of data on the same plot or is what you really care about is that the two sets of data are in the same graph? If it's the former, then there's not much that you can do since a plot can only contain one set of data. You can append to an existing set of data by calling the corresponding Chart (for example, ChartXvsY) method, but the result is that the plot's data will appear continuous.

If it's the latter, the way to do this is to add multiple plots to the graph and plot each set of data in a separate plot. For example, go to the Plots tab in the graph's property pages, add another plot, then here's some sample code that demonstrates how to plot the sets of data from your example above:

double xData1[] = { 1, 3, 5, 8 };

double yData1[] = { 3.5, 2.3, 1.3, 3.2 };
CNiReal64Vector xDataSet1(4, xData1), yDataSet1(4, yData1);
m_graph.Plots.Item(1).PlotXvsY(xDataSet1, yDataSet1);

double xData2[] = { 1, 2.5, 4 };
double yData2[] = { 2.3, 5.4, 2.5 };
CNiReal64Vector xDataSet2(3, xData2), yDataSet2(3, yData2);
m_graph.Plots.Item(2).PlotXvsY(xDataSet2, yDataSet2);

Hope this helps.

- Elton
Message 2 of 2
(2,993 Views)