I have a data visualisation task for class and need to show how temperature changes over time. My idea is to have the fill react to the temperature values.
So, I have an array of float values (length is 1438) taken from a csv file and I want the fill to change based on these values.
I’ve tried using an enhanced for loop with if statements, but only the last statement seems to be in effect. However, I need to be able to see each colour change instead.
Below is my for loop and if statements. Sorry for any mistakes, I’m a total noob.
//conditions
for (float ai: arrayInventory) {
if (ai > 24.00) {
fill (heatwave [1]);
} else {
fill(heatwave [0]);
}
if (ai > 26.00) {
fill (heatwave [2]);
} else {
fill(heatwave [1]);
}
if (ai > 28.00) {
fill (heatwave [3]);
} else {
fill(heatwave [2]);
}
if (ai > 30.00) {
fill (heatwave [4]);
} else {
fill(heatwave [3]);
}
if (ai > 32.00) {
fill (heatwave [5]);
} else {
fill(heatwave [4]);
}
if (ai > 34.00) {
fill (heatwave [6]);
} else {
fill(heatwave [5]);
}
if (ai > 36.00) {
fill (heatwave [7]);
} else {
fill(heatwave [6]);
}
if (ai > 38.00) {
fill (heatwave [8]);
} else {
fill(heatwave [7]);
}
println (ai);
}