HELP with scatter data plot?
in
Programming Questions
•
1 year ago
Hi. I'm trying to do something fairly simply: a XY scatter plot of data. The data is appearing properly but I have 2 questions:
1. any way to make the data appear faster? It takes a while for it all to appear
2. ultimately I want the user to be able to select a team (team affiliation is one of the data elements) and see the plot points associated with that team appear in a different color. I inserted a statement (line 28) as a test - to see if all data points associated with the team "BOS" would appear a different color - but it didn't work.
Any help would be appreciated! Thanks!
Kevin
1. any way to make the data appear faster? It takes a while for it all to appear
2. ultimately I want the user to be able to select a team (team affiliation is one of the data elements) and see the plot points associated with that team appear in a different color. I inserted a statement (line 28) as a test - to see if all data points associated with the team "BOS" would appear a different color - but it didn't work.
Any help would be appreciated! Thanks!
Kevin
- String [] lines;
- int index = 0;
- int T = 2; //cell location in data file for team
- int N = 1; //cell location in data file for name
- int A = 3; //cell location in data file for age
- int W = 5; //cell location in data file for WAR
- int ColorR;
- int ColorG;
- int ColorB;
- void setup() {
- size(1280, 760);
- PFont font = loadFont("HelveticaNeue-Light-20.vlw");
- textFont(font);
- lines = loadStrings("PlayerWAR.txt");
- }
- public void draw() {
- if (index <lines.length) {
- String[] pieces = split(lines[index], '\t');
- float age = float(pieces[A]);
- float WAR = float(pieces[W]);
- String team = pieces[T];
- String name = pieces[N];
- float buffer = random(0,1);
- float adjWAR=(WAR*100);
- float adjage=50+(((age+buffer)-19)*20);
- if (pieces[T]=="BOS") {
- ColorR=247;
- ColorG=82;
- ColorB=33;
- }
- else
- ColorR=150;
- ColorG=150;
- ColorB=150;
- smooth();
- strokeWeight(1);
- stroke(100);
- fill(ColorR,ColorG,ColorB);
- ellipse(adjWAR,adjage,5,5);
- index = index +1;
- }
- }
1