FORUMS: list search recent posts

Advise needed: Plugin for importing CSV data to a scatter plot

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Søren Storm
Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 7, 2016 at 8:47:15 pm

Hello Forum, and thank you for reading this!

I´m doing science videos, and I need to present a graph, with scattered XY data from an experiment.

I´m pretty new to AE, so until now, I have done my graphs in Illustrator, seperate in two layers, one for axis / titles, and one layer for data points. Revealing data has been done by unmasking the datalayer on top of the axis/titles layer. It is an ok way of doing it, but still has it´s upsides and downsides. Especially if there is changes to the dataset, or a new dataset comes along.

I saw that some plugins were able to extract text from a CSV file, for lower thirds, and thought, "hey, maybe I´m able to get data for a graph with a plugin". I haven´t found any, so now I´m wondering if anyone knows of any plugin or combination of plugins that will do the trick?

Best regards
Søren


Return to posts index

Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 7, 2016 at 9:22:26 pm

Looks like this might help you out:

http://aescripts.com/aeinfographics/

Joe Clay
Workbench.tv


Return to posts index

Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 8, 2016 at 7:40:47 am

Thank you Joe :-)

But as I see it, this plugin only transfers a text and a value, not a x value and a y value. So I might buy it and try to edit it to do what I need :-)

Best regards
Søren


Return to posts index


Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 8, 2016 at 2:56:22 pm

Ah. I see, it's more for charts not so much graphs. I would be surprised if no one has made something that does that.

Joe Clay
Workbench.tv


Return to posts index

Walter Soyka
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 12:28:41 am

Are you familiar with expressions in Ae? You could parse a CSV file with a few expressions if you haven't found anything else.

What does your dataset and graph look like?

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 5:05:10 am

True, but wouldn't you need a script for anything meaningful? I mean you'd probably want separate layers or at least separate paths in a shape layer.

Joe Clay
Workbench.tv


Return to posts index


Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 9:06:00 am

I think paths into a shape layer would be the way to go. I have MANY coordinates. Wouldn´t it be confusing with 500+ layers?


Return to posts index

Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 9:03:22 am

I think I get what you mean. I have done some scripts in the past, but nothing fancy. I have done some basic copy paste scriptning, were I needed a plane to follow a parabolic path, which involved editing existing code.

I have an idea of what the overall code might do:

1) Read file, find number of coordinate pairs (x, y), and determine max / min values

2) Read coordinates into an array (I guess)

3) Convert coordinates to fit on the screen (x_max = 1920, y_max=1080, minus some space for the graph axis)

4) Put each coordinate into a shape (a small circle), in a shape layer

And that would be it. Later on I would like to experiment with things like letting the coordinates scroll through the screen (if its a large dataset). This I guess could be achieved by setting the coordinate for each frame, minus e.g. the framenumber, and masking the coordinates out.

BUT: I have no clue on how to do 1) - 4). Any help would be greatly appreciated! :-)

Best regards
Søren


Return to posts index

Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 9:09:12 am

Sorry - the file was not included. I have the example here; from dropbox:

https://www.dropbox.com/s/620fpaod9ezwuhn/example.txt?dl=0

If you can´t read it; I have copy pasted part of it here:
Time (s) Pulse (BPM)
1 71
2 71
3 72
4 65
5 65
6 64,875
7 64,75
8 64,625
9 64,5
10 64,375
11 64,25
12 64,125
13 64
14 65
15 65,6667

...And so on for 2000 seconds.


Return to posts index


Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 2:55:22 pm

Randomly, I ended up helping a friend last night with a quick script to import text and scale values from a CSV for a tag cloud, and it was easy enough to modify to create this rough script. I've never created shape layers before, so I didn't put in an actual shape yep, but this makes the layers, spaces them out by 10px, and starts the graph from 1,1080 in the corner (I set it up for an HD comp).

Here's the script: https://www.dropbox.com/s/qyiuf90cxyifw9b/wbGrapher.jsx?dl=0

So to use it, you just run it and import your csv (I had to take your csv and modify it because csv's don't like decimals that have commas. :) I used numbers to do it but I'm sure you can do it in Google Docs or Excel. You'll need to do it in an editor that's not a text file so it doesn't remove the commas you need to split the data. Anyway, find and replace your commas with periods. And then take off the headings. So it should just be your numbers.

Then on the first shape layer, add your shape. You can put a simple circle and fill, or whatever you want. Then, copy everything under contents in the shape and select all the remaining layers and paste it. Then just put a null at 1,1080, and parent all of your layers to it. You can scale the null or whatever to change the graph. If you like you can also modify the script. You might want to add a multiplier to the y values. You can scale the null x and y differently, but it'll stretch the contents of the shape of course.

I might change the script in the future, so if anyone comes along, hit me up here and I'll relink a new one if it's no longer there. I hope this helps!

Joe Clay
Workbench.tv


Return to posts index

Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 3:01:26 pm

Wow! Thank you! I can't wait to check this out! I'll be back with the result of your work! Thanks Joe!!


Return to posts index

Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 3:17:11 pm

No 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


Return to posts index


Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 9, 2016 at 7:55:00 pm

I 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 :-)


Return to posts index

Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 12, 2016 at 8:54:16 pm

Hi 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 data

BUT:
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 :-P 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


Return to posts index

Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 17, 2016 at 7:28:40 am

Haha, 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.height

If 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


Return to posts index


Søren Storm
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 17, 2016 at 7:44:57 am

Cool 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! :-)


Return to posts index

Joe Clay
Re: Advise needed: Plugin for importing CSV data to a scatter plot
on Jun 17, 2016 at 7:21:38 pm

Oh 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]