Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

scattergraph labeling and y-axis assigned issue

Hi, I am using Visual Studio C# to plot multiple sets of y data that corresponds to the same X-axis in my very simple code.

 

There are 3 curves in my plot, and two of them belongs to the y-axis on the right and the third one belongs to the one on the left.

 

However, I do not know how to assign the data to the appointed y-axis I want.

 

Also, I need to show the label for each curve so that the user can know the meaning of each curve. (The Legend I mean)

 

Can anyone help me with this?

 

thanks.

 

The following is the code I have done. (The array dataY, dataZ, and dataW serves as y value, and they all corresponding to the dataX.)

 

using NationalInstruments;
using NationalInstruments.DAQmx;
using NationalInstruments.Max;
using NationalInstruments.UI;
using NationalInstruments.UI.WindowsForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double[] dataX = new double[3];
double[] dataY = new double[3];
double[] dataZ = new double[3];
double[] dataW = new double[3];


ScatterPlot Id = new ScatterPlot();
ScatterPlot Gm = new ScatterPlot();
ScatterPlot Ig = new ScatterPlot();

private void button1_Click(object sender, EventArgs e)
{
dataX[0] = 1; dataY[0] = 4; dataZ[0] = 9; dataW[0] = 5;
dataX[1] = 2; dataY[1] = 2; dataZ[1] = 11; dataW[1] = 5;

dataX[2] = 3; dataY[2] = 3; dataZ[2] = 7; dataW[2] = 5;


scatterGraph1.Plots.Add(Id); scatterGraph1.Plots.Add(Gm); scatterGraph1.Plots.Add(Ig);
Id.LineColor = Color.Red;
Gm.LineColor = Color.Purple;
Ig.LineColor = Color.Blue;

scatterGraph1.Caption = "VgId plot";


Gm.PlotXY(dataX, dataZ, 0, 3);
Id.PlotXY(dataX, dataY, 0, 3);
Ig.PlotXY(dataX, dataW, 0, 3);

 





}


}
}

0 Kudos
Message 1 of 3
(5,888 Views)

Hi johsieh74326,

 

I have found a KnowledgeBase article that discusses the issue that seems to be related. I have included it below and I hope it helps!

 

Assign a Plot to Y-axis: http://digital.ni.com/public.nsf/allkb/669DCC21EC883A0D862565150047B0B4?OpenDocument

 

Regards,

 

Jason D

Applications Engineer

National Instruments

 

0 Kudos
Message 2 of 3
(5,861 Views)

I didn't see an answer to the portion of the question about identifying plots with a legend.   Did I miss it?

 

0 Kudos
Message 3 of 3
(3,269 Views)