Activity › Forums › Adobe After Effects › Advise needed: Plugin for importing CSV data to a scatter plot
-
Advise needed: Plugin for importing CSV data to a scatter plot
Joe Clay replied 9 years, 11 months ago 3 Members · 16 Replies
-
Joe Clay
June 9, 2016 at 3:17 pmNo problem! Hopefully it’s what you’re looking for. If not maybe I can modify it to help. Just let me know.
Joe Clay
Workbench.tv -
Søren Storm
June 9, 2016 at 7:55 pmI can read data into after effects 🙂 Thank you Joe. It works!
I did one change to your code, because it´s not always a time in seconds on the first axis. So that part I´ve changed to:textLayer.position.setValue([text[0],1080-text[1]]);I have some questions about your code, and how to implement stretching the data, with a max min search in. But it´s late here – and so I will crash. Thank you again. You brought me a great leap forward 🙂
-
Søren Storm
June 12, 2016 at 8:54 pmHi Joe (and creative cows in general)!
Thank you for getting me started on scriptning. It´s been great getting into it. Spend the last couple of evenings scriptning my very own pretty ok system for making coordinate systems of various dimensions. The result is here:

Example of a plot from the script: You can download the script to test it yourself here: 10189_graph.jsx.zip-You can input number of (datadividers? Can´t figure out the english term for it)
-You can input dimensions (both axis)
-Future functionality: Axis labeling, by prompting
-Future functionality: x and y axis scale suggestions from reading spreadsheet dataBUT:
1) I am stuck on reading the maximum value of the arrays x values and y values into two seperate variables, in the script you wrote for me. For this reason I have not combined your script with my code yet. I tried math.max.apply, but get errors… I don´t even know if it´s an array you generate 😛 I need this to automate sizing of the graph and a couple of other things.2) I want to be able to center the texts under each datadivider, even though I use
myText.justification = ParagraphJustification.CENTER_JUSTIFY;
It seems not to center it, as can be seen on the x-axis on the example png.3) Is there a smarter way of reading comp dimensions, than my rough input in the beginning of the script?
screen_width = 1920;
screen_height = 1080;4) I have an inherent problem with variable names. They get very long. Sorry.
I really hope you can help me with 1)-3). I´m beyond help with 4).
Best regards
Søren -
Joe Clay
June 17, 2016 at 7:28 amHaha, that’s awesome! I’m glad you got into it! Sorry I didn’t see this sooner. I’m glad I came across it! I wish there was a way to set the forum to auto subscribe me when I comment without me having to remember to check it!
Anyway let’s see here.
1. I modified someone’s importer. Their code had an issue reading lines for some reason. So since I just needed to display data, I populated it right from the original loop. Theirs used that split() method to split the entire file by the commas, but a lot of CSVs don’t have the ending comma at the line, and it became a hassle trying to add it back it and getting it to work correctly. Anyway, you can store the data into an array. I’d probably make it into an array of objects. This is some pseudo code that should explain it. Unfortunately, PHP is a lot more convenient in a lot of things and I think of that first (especially with arrays!) so I can’t guarantee this works out of the box.
Before the loop set up a variable:
var data = new Array();And during the file reading loop instead of adding the shape do something like this:
datapoint.x = text[0];
datapoint.y = text[1];
data[] = datapoint;
Anyway, I was thinking about that if I were to expand it further in the future. Also, set up a variable for the max outside the loop, let’s call it maxValue.
var maxValue;Then in the loop:
if(text[0] > maxValue.x) { maxValue.x = text[0] };
if(text[y] > maxValue.y) { maxValue.y = text[0] };You might have to initialize maxValue.x and maxValue.y as 0.
Then you’ll have the results when the loop is done. Make a new function to display the values, and call it. It’ll contain something like this:
for (i = 0, i < data.length; i++) {
textLayer = comp.layers.addShape();
textLayer.position.setValue([data[i].x*10,1080-data[i].y]);And of course you’d need to add in your code that would deal with the max values. I might get to this one day. Haha. But I think it’s awesome how far you’ve come—it’s especially amazing that you hadn’t done any scripting before. AE can be an especially large pain in that regard.
2. That one I’m not sure of. I haven’t done much with text. I did notice that the justification isn’t actually centered for some reason, so I changed them in the comp but it still wasn’t quite right for some reason.
3. I think in your code you could define myComp earlier, probably at the top. Then you can just do:
myComp.width
and
myComp.heightIf I recall correctly.
4. Haha, I try to keep mine short usually, but it’s never a bad habit to be descriptive!
Joe Clay
Workbench.tv -
Søren Storm
June 17, 2016 at 7:44 amCool thanks! 🙂 Now I have something to work on. I have done some scripting in Linux for some MD simulations, so I´m not completely green. The scripts I worked on there was mainly file maintenance (incredibly important when you run 50 simulations with huge amounts of xyz files (for each frame), waiting for simulated crystal to settle. All simulation packages was NOT done by me, But it´s already 3 years ago. It´s incredibly rewarding when it works out, so I guess that´s been my main motivation – that it may actually work 🙂 Also it pains me physically to do stuff again and again, that can be done better by a computer.
The scripting I did in the MD simulations was mainly C++, but the syntax… Damn. How on earth did people learn how to program before google came along?
Thanks again Joe! I will return when I have had some spare coding time again! 🙂
-
Joe Clay
June 17, 2016 at 7:21 pmOh nice! If I get some time I might expand upon the one I built already. Worse to worse I might at least be able to get it to the point where you have an array with the data values you need to merge the two scripts.
And yes, I completely agree. Weren’t computers supposed to stop us from having to waste our time on repetitive tasks!? Haha. Have a great weekend!
Joe Clay
Workbench.tv
Reply to this Discussion! Login or Sign Up