3

I'm looking for a way to graph multiple point within an (X,Y) plane, and have them appear (then disappear) one at a time. I have a total of about 400 (x,y) points, which are position tracking information gathered from a Inertial Measurement Unit.

Each data point is separated by approx 4 ms (I can change this interval to make it longer), so if possible, I would like to display one dot at a time, each for 4ms, until the next dot appears. The final product should display the object's movement path over the 5-6 second sample time. From my excel file, I have two columns (one for X and one for Y) which are 400 elements long (400 rows).

I'm hoping for a way to plot the X,Y scatter information one row at a time, and looking for some code that will increment through each row and plot the corresponding scatter. I am a semi-fluent programmer, but have never used MS Visual Basic before. All the solutions for Excel that I have found so far (which are similar to my problem) involve writing code for the graph in Visual Basic. I think I may be able to get that working, if someone can help me with the code... but if there is another piece of software which does this (for free! I'm on a student budget!) then I am willing to try multiple solutions.

I found this code already:

Sub Macro1()
   Charts.Add
    ActiveChart.ChartType = xlXYScatter
    ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A3:B3"), PlotBy _
        :=xlColumns
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
    With ActiveChart.Axes(xlCategory)
        .MinimumScale = -30
        .MaximumScale = 30
        .MinorUnit = 1
        .MajorUnit = 5
        .Crosses = xlAutomatic
        .ReversePlotOrder = False
        .ScaleType = xlLinear
        .DisplayUnit = xlNone
    End With
    With ActiveChart.Axes(xlValue)
        .MinimumScale = 0
        .MaximumScale = 2800
        .MinorUnit = 50
        .MajorUnit = 100
        .Crosses = xlAutomatic
        .ReversePlotOrder = False
        .ScaleType = xlLinear
        .DisplayUnit = xlNone
    End With
     For I = 3 To Worksheets(1).Range("A65536").End(xlUp).Row
    ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A3:B" & I), PlotBy _
        :=xlColumns
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ST = Timer
    While Timer < ST + 1
    Wend
    Next I
End Sub

However, being as there was no comments or documentation, I had difficulty perusing through it and picking it apart. I feel like once I can really understand the format of Visual basic I can modify the program to adapt for my specific needs... but understanding it is the first step.

So again, my information is in the format of 3 columns: X displacement -- Y displacement -- Timestamp (position in mm) (position in mm) (seconds, or iteration #, whichever is easier)

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Rob Coke
  • 31
  • 2
  • I'm sorry, I realize that the code got all screwed up when I tried to paste it... I also found this blog which seemed to do what I need, but I found the code explanation fairly vague... http://www.vbadventure.com/2011/11/animated-charts-in-excel/ – Rob Coke Mar 22 '13 at 20:59
  • Try re-formatting your code by indenting each line 4 spaces. Probably easiest to do this in Excel's VBE and use the tab option. – David Zemens Mar 22 '13 at 21:09
  • I've written a few tutorials about animating Excel charts: http://peltiertech.com/WordPress/gas-prices-animated-bar-chart-for-excel-2/, http://peltiertech.com/WordPress/rolling-wheel-animation/, http://peltiertech.com/WordPress/ballistics-animation/, http://peltiertech.com/WordPress/gapminder-for-excel-ii/. – Jon Peltier Apr 03 '13 at 12:23

0 Answers0