Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scattergraph 2 independant xy plots

I am looking to have a graph that shows two plots.  I need two independant x-axis (for the odd occurance that one device has more readings than the other) and two independant y-axis.  I can get one graph to show up but I don't know how to get the second one to show up.  I need to be able to graph them independant of each other.  The user picks from 2 dropsdowns  .  Once the dropdowns are choicen the axises are labeled and the graph is made.  I have attached my code.  Can someone please help me with getting both graphs to show up and not just one.
 
0 Kudos
Message 1 of 6
(3,564 Views)
Hi jharwood,

You need to create a separate ScatterPlot for each plot, associate it with unique axes, associate the graph with these axes, and then add the plots to the graph. Here is the code in C#, the ideas should be similar VB:

                        XAxis xAxis1 = new XAxis();
            xAxis1.Range = new Range(0, 10);

            YAxis yAxis1 = new YAxis();
            yAxis1.Range = new Range(0, 10);

            ScatterPlot plot1 = new ScatterPlot(xAxis1, yAxis1);
            plot1.PlotXY(new double[] { 0, 1, 2 }, new double[] { 0, 1, 2 });

            XAxis xAxis2 = new XAxis();
            xAxis2.Range = new Range(0, 20);

            YAxis yAxis2 = new YAxis();
            yAxis2.Range = new Range(0, 20);

            ScatterPlot plot2 = new ScatterPlot(xAxis2, yAxis2);
            plot2.PlotXY(new double[] { 0, 10, 20 }, new double[] { 20, 10, 0 });

            scatterGraph1.XAxes.Add(xAxis1);
            scatterGraph1.YAxes.Add(yAxis1);
            scatterGraph1.XAxes.Add(xAxis2);
            scatterGraph1.YAxes.Add(yAxis2);

            scatterGraph1.Plots.Add(plot1);
            scatterGraph1.Plots.Add(plot2);


Regards,
0 Kudos
Message 2 of 6
(3,537 Views)

Thanks for the help James.  Once I got the code converted it worked like a charm except that I get multiple axises that don't contain anything.

I have attached my code for reference.

0 Kudos
Message 3 of 6
(3,529 Views)
Here is the picture of what it is doing.
0 Kudos
Message 4 of 6
(3,520 Views)
Hi jharwood,

The other plots are probably hanging from the graph configuration at edit time. Before you add the new axes to the graph programmatically, just call Graph.XAxes.Clear() and Graph.YAxes.Clear().

Regards,
0 Kudos
Message 5 of 6
(3,511 Views)
Worked Perfect Thanks.  I also needed graph.plots.clear()  so that if I select something else from the drop downs that the original graph would disappear.
 

 

 

0 Kudos
Message 6 of 6
(3,506 Views)