void setup() { size(400, 400); background(255); int numCells = 10; // Number of cells in each direction int cellSize = width / numCells; // Size of each cell // Draw grid of rectangles for (int i = 0; i < numCells; i++) { for (int j = 0; j < numCells; j++) { int x = i * cellSize; int y = j * cellSize; rect(x, y, cellSize, cellSize); } } // Draw x-axis stroke(0); line(0, height / 2, width, height / 2); // Draw y-axis line(width / 2, 0, width / 2, height); // Plot and connect points float[] xValues = {0, 1, 2, 3, 4, 5}; float[] yValues = {1, 4, 2, 6, 3, 5}; for (int i = 0; i < xValues.length; i++) { // Map points to the grid float mappedX = map(xValues[i], 0, 5, 0, width); float mappedY = map(yValues[i], 0, 6, height, 0); // Plot points fill(255, 0, 0); // Red color ellipse(mappedX, mappedY, 10, 10); // Connect points with lines if (i > 0) { float prevMappedX = map(xValues[i-1], 0, 5, 0, width); float prevMappedY = map(yValues[i-1], 0, 6, height, 0); line(prevMappedX, prevMappedY, mappedX, mappedY); } } }