Hello! I am using data from my CSV file to plot ellipses. It is working when I do it one by one, but when I add an array in to create ellipses from every row of the data, I’m just getting a straight line from them.
Here is an example of what I’m trying to do:
size(600, 400);
background(0);
Table table = loadTable("Data01.csv", "header");
TableRow row = table.getRow(0); // Getting the row
float x = row.getFloat("X"); //int in first column
float y = row.getFloat("Y"); // int in second column
float x_ = map(x, 0.24375, 0.509375, 0, 600); // mapping lowest csv number and highest csv number
float y_ = map(y, 0.24375, 0.509375, 0, 400);
println(x_,y_);
ellipse(x_, y_, 25,25);
TableRow row2 = table.getRow(1); // Getting the row
float x2 = row2.getFloat("X"); //int in first column
float y2 = row2.getFloat("Y"); // int in second column
float x2_ = map(x2, 0.24375, 0.509375, 0, 600);
float y2_ = map(y2, 0.24375, 0.509375, 0, 400);
println(x2_,y2_);
ellipse(x2_, y2_, 25,25);
TableRow row3 = table.getRow(2); // Getting the row
float x3 = row3.getFloat("X"); //int in first column
float y3 = row3.getFloat("Y"); // int in second column
float x3_ = map(x3, 0.24375, 0.509375, 0, 600);
float y3_ = map(y3, 0.24375, 0.509375, 0, 400);
println(x3_,y3_);
ellipse(x3_, y3_, 25,25);
Obviously I can’t do this for hundreds of rows, so this is what I have done to try to go through every row to do the same thing:
void setup() {
size(600, 400);
background(0);
noLoop();
}
void draw() {
loadData();
}
void loadData() {
Table table = loadTable("Data01.csv", "header");
for (int i = 0; i < table.getRowCount(); i++) {
TableRow row = table.getRow(i);
float x = row.getFloat("X");
float y = row.getFloat("Y");
float x_ = map(x, 0.24375, 0.509375, 0, 600);
float y_ = map(y, 0.24375, 0.509375, 0, 400);
fill(255);
ellipse(x_, y_, 10, 10);
println(x_, y_);
}
}
Instead of plotting the ellipses according to the x and y values, it seems to be putting them in a straight diagonal line and I’m not sure what I’m doing wrong. Thank you in advance for any help!