Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Plotting Graphs by Arrays


Hi there,
I have a problem here that mey be quite easy to sort out as I think i
is merely a syntax problem - or someone may be able to suggest a wa
around using arrays full stop. I want to plot scatter graphs for som
data I have availiable, but it is of varying length (typically betwee
6 and 24 samples). I have two proceedures, the first gathers the dat
and assigns this to arrays, and the second one plots them. Now, bot
worked independantly (the graph plotter was using a range rather tha
an array) but when I tried passing the arrays to the second sub, i
wouldn't work.

Option Explicit

Sub AssignValues()
Dim i As Integer
Dim valueX() As Single
Dim valueY() As Single

'Obtain all the transmission times in milli-seconds (or the
axis).
i = 0
Worksheets(1).Range("B1").Offset(6, 1).Activate
Do
ActiveCell.Offset(0, 1).Activate
ReDim Preserve valueY(i)
valueY(i) = ActiveCell.Value
i = i + 1
Loop While ActiveCell.Offset(0, 1).Value < ""

'Obtain all the lung volumes in litres (or the X axis).
i = 0
Range("B1").Offset(5, 1).Activate
Do
ActiveCell.Offset(0, 1).Activate
ReDim Preserve valueX(i)
valueX(i) = ActiveCell.Value
i = i + 1
Loop While ActiveCell.Offset(0, 1).Value < ""
Call PlotGraph(valueX(), valueY())
End Sub

Sub PlotGraph(valueX() As Single, valueY() As Single)
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A25")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = valueX
ActiveChart.SeriesCollection(1).Values = valueY
ActiveChart.SeriesCollection(1).name = "=""AM Channel 1"""
ActiveChart.Location Whe=xlLocationAsObject, name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "AM Title"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "
lable"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "
lable"
End With
ActiveChart.HasLegend = False
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 15
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
ActiveChart.Axes(xlValue).MajorGridlines.Select
With Selection.Border
.ColorIndex = 15
.Weight = xlHairline
.LineStyle = xlContinuous
End With
End Sub

Now any comments would be appreciated. As you can tell the second su
was recorded rather than written, so any comments on how to smarten i
up would be appreciated.

I am going to anticipate a question that some of you may be thinking
whay plot from arrays? Well, I would rather not, and just plot fro
ranges but I don't know how (I'm aware that plotting from arrays has
limit on the characters you can use). An ideal answer to this proble
I suppose would be a way to plot variable lengths of rows into chart
(continued up until the next cell is empty). This is what I originall
tried to do but failed.

Thanks in advance,
Dave..

--
d.i.bar
-----------------------------------------------------------------------
d.i.barr's Profile: http://www.excelforum.com/member.php...fo&userid=1552
View this thread: http://www.excelforum.com/showthread.php?threadid=31937

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel plotting graphs Qmm Charts and Charting in Excel 2 March 18th 08 04:39 PM
avoiding plotting zero values on graphs Lee Charts and Charting in Excel 1 November 22nd 05 02:15 AM
Problem with plotting a chart when using arrays as Values and Xvalues [email protected] Charts and Charting in Excel 3 August 19th 05 09:05 PM
Plotting Graphs Dharsh Excel Discussion (Misc queries) 2 May 24th 05 01:58 PM
plotting graphs johnd Charts and Charting in Excel 1 March 11th 05 12:52 AM


All times are GMT +1. The time now is 06:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"