PDA

Click to See Complete Forum and Search --> : Plotting a line graph from a 2d array


timbo
Aug 27th, 2000, 04:24 PM
Hi

I am trying to create a (single) line graph by plotting points from a 2d array. This following code is within a Private Sub Command1_Click() where the values within the arrays' are calculated also. It gives me q number of lines rather than a single line plotted from q number of points.

Should I use a scatter graph instead?

Thanks in advance

Dim Data() As Double

ReDim Data(1 To 2, q) As Double

q = 1

Do Until q = p

Data(1, q) = voltageClampArray(23, q) 'time
Data(2, q) = voltageClampArray(7, q) 'current

q = q + 1

Loop

'plot data
With MSChart1

.Plot.Axis(VtChAxisIdX).CategoryScale.Auto = True
.Plot.Axis(VtChAxisIdX).CategoryScale.DivisionsPerTick = q / 10
.Plot.SeriesCollection(1).Position.Excluded = True 'hide time data
.chartType = VtChChartType2dLine
.ChartData = Data()

End With

'check values in array are correct
q = 1
Do Until q = p
Print Data(2, q)
q = q + 1
Loop