Plot Values
in
Programming Questions
•
3 months ago
Hello all.
I want to plot a series of data from an external file. I want to set a point to the X axis that represent the minutes for each value, i.e. using a csv file with a
Row1: Year Minute Value
Row2: 2013 56 7.2
Row3: 2013 57 3.4
The following loop visualizes the data with no problem if the initial value of minute is 0. In other cases that the minute is 50 for example, it doesn't start counting and visualizing, unless it goes back to 0.
//Using FloatTable class from book Visualizing Data
void drawDataPoints(int col) {
int rowCount = data.getRowCount();
for (int i = 0; i < rowCount; i++) {
float value = data.getFloat(i, col);
float x = map(minutes[i], 0, rowCount, plotX1, plotX2);
float y = map(value, data.getTableMin(3), data.getTableMax(3), plotY2, plotY1);
point(x, y);
}
}
So how can I use this loop to map for the X so that it starts from the minute value coming from the first usable row (i.e. Row 2), no matter what the number of the minutes is, and ends at the final row of the table?
1