void drawXLabels() { fill(70); textAlign(CENTER, TOP); // Use thin, gray lines to draw the grid stroke(0,120); strokeWeight(1); for (int row = 0; row <= XMAX; row++) { if (row % XINTERVAL == 0) { float x = map(row, XMIN, XMAX, PLOTX1, PLOTX2); textFont(font); if (row == XMIN) { textAlign(LEFT, CENTER); // Align by the bottom } else if (row == XMAX) { textAlign(RIGHT, CENTER); // Align by the top } else { textAlign(CENTER, CENTER); // Center vertically } fill(70); text(row, x, PLOTY2 + 10); line(x, PLOTY1, x, PLOTY2+5); } } } void drawYLabels() { fill(70); textFont(font); stroke(128); strokeWeight(1); for (float v = DATAMIN; v <= DATAMAX; v += YINTERVAL) { if (v % YINTERVAL == 0) { // If a tick mark float y = map(v, DATAMIN, DATAMAX, PLOTY2, PLOTY1); if (v % YINTERVAL == 0) { // If a major tick mark if (v == DATAMIN) { textAlign(RIGHT); // Align by the bottom } else if (v == DATAMAX) { textAlign(RIGHT, TOP); // Align by the top } else { textAlign(RIGHT, CENTER); // Center vertically } text(floor(v), PLOTX1 - 7, y); line(PLOTX1 - 4, y, PLOTX1, y); // Draw major tick } else { line(PLOTX1 - 2, y, PLOTX1, y); // Draw minor tick } } } } void drawGrid() { stroke(255, 100); strokeWeight(.5); for(int i = 0; i < width; i = i + gridInterval) { line(i,0,i,gridInterval*6); for(int k = 0; k < gridInterval*6; k = k + gridInterval) { line(0,k,width,k); } } } void drawPlot() { noStroke(); fill(70); rectMode(CORNERS); rect(PLOTX1,PLOTY1,PLOTX2,PLOTY2); } void drawAxisLabels() { fill(70); textLeading(15); textFont(font); textAlign(CENTER, CENTER); // Use \n (enter/linefeed) to break the text into separate lines text("Y-AXIS\nLABEL", LABELX, (PLOTY1+PLOTY2)/2); textAlign(CENTER, CENTER); text("X-AXIS LABEL", (PLOTX1+PLOTX2)/2, LABELY); } void drawTitle() { fill(70); textAlign(LEFT); textFont(font); text("SPL DATA VISUALIZATION", PLOTX1, PLOTY1 - 5); textAlign(RIGHT); text("MAT 259", PLOTX2, PLOTY1 - 5); }