var table; var nCol; var nRow; var orgX; var orgY; var widthXLine; // x-axis width var lengthYLine; // y-axis length var widthXSubset; // width for a subset which is the length of x-axis and space var lengthYSubset // length for a subset which is the length of y-axis and space var yCol; var xCol; var nameCol = 12; var n = 4; // Numbers of variable to display var list_variable = new Array(0,6,10,16) // The list of column want to show var list_variable_name = new Array("City mpg","Highway mpg","Length","Width"); var headline = "Car Size and Fuel Economy" var xSize = 1600; // Size of Canvas var ySize = 1600; function preload(){ table = loadTable('cars.csv','csv','header'); } function setup() { createCanvas(xSize,ySize); nCol = table.getColumnCount(); nRow = table.getRowCount(); orgX = 100; orgY = ySize - 100; widthXSubset = (xSize-200)/n; lengthYSubset = (ySize -200)/n; widthXLine = widthXSubset*0.8; lengthYLine = lengthYSubset*0.8; // Set line length, to be 90% of subset in order to leave space if(lengthYLine>widthXLine){ lengthYLine = widthXLine; } else if(widthXLine > lengthYLine){ widthXLine = lengthYLine; } // Here make the axis be symmetric } function draw() { background(255); for(var hor=0; hor xMax){ xMax = Number(table.getString(i,xCol)); } if(Number(table.getString(i,yCol)) > yMax){ yMax = Number(table.getString(i,yCol)); } } // Find the maximum value of x-axis and y-axis xWidth = widthXLine/xMax; yLength = lengthYLine/yMax; //print(widthXLine+", "+xWidth); //print(lengthYLine+", "+yLength); for(var c = xMax/10; c