[RESOLVED] Creating a dynamic graph to visualise movement
Hey all,
I'm modelling insects, and I've reached the point of making them migrate (Success!). Unfortunately, It's pretty hard to tell whether the code is working as it should be, as all I see are lists of coordinates. Does anyone know how I could go about making a graphical visualisation of these insects?
For some details; I have plants and insects, each plant has a patch number and an x, y coordinate. Each insect is on a plant, and it shares the patch/coordinates of its host plant. (These data are stored in a plant and insect array).
The way I imagine I would go about this is to make a graph, X coordinates on X axis, Y on Y. I would then print the plant data on an excel sheet, and put circles on the graph using the coordinates (different patches would be represented by different colour circles). I'd then do the same for the insects. Then, I'd make a sub where each time an insect moves, the graph is updated to show it's new location/patch. I think that's about it...
Does anyone see any issues with how this would work, or have any advise as to how to do it effectively?
Re: Creating a dynamic graph to visualise movement
Are you able to create the graph as you describe it manually? If so, then you could write code to update it based on some "change event" (not sure how you're making the insects move exactly).
Re: Creating a dynamic graph to visualise movement
I have no clue how to make the graph, but I'm currently reading up on it.
I don't think a change event would be suitable. What I have is a sub that takes the current location of an insect, does some maths to decide where it moves, then changes its coordinates/patch to those of the new plant. Of course, in the final model this will happen hundreds of times per loop.
This graph tool won't be a thing that I'm using in any final model though, it's just a tool I need now to ensure that my code is working as intended.
EDIT: I didn't even address your question haha! By manually do you mean making it manually in excel then manipulating with code? I intend to do everything via VBA.
Re: Creating a dynamic graph to visualise movement
Have a look at a scatter graph. You may need to convert the x,y coordinates depending on the size.
Add series for the plant locations
Add series for bug locations... Again you'll need to experiment to see what works best (assuming lots of bugs all moving...
I guess (having not made a dynamic graph) that there is a refresh method on the graph that could be called either x time or after each update to the positions.... the latter being slow to show but more accurate.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: Creating a dynamic graph to visualise movement
Cheers for your advise guys!
I ended up spending some time making a scatter graph manually, and at some point I'll just try produce code which will update it, which shouldn't be too difficult.