rokefeller
YaBB Newbies
Offline
Posts: 2
plotting data to x and y coordinates for an array
Feb 26th , 2010, 2:46pm
I want to plot data for the x and y coordinates of an array of images (country flags) so that the x value equals the gnp of the country and the y value equals the surface area of that country any help would be greatly appreciated I already have all my data. Here is my code so far. Table locationTable; int rowCount; PFont font; PImage[] img = new PImage[300]; void setup() { size(1250, 750); font = loadFont("Times-Roman-14.vlw"); textFont(font); // Make a data table from a file that contains // the coordinates of each state. locationTable = new Table("myurladdress"); // The row count will be used a lot, store it locally. rowCount = locationTable.getRowCount(); for (int row = 0; row < rowCount; row++) { String code = locationTable.getString(row, 0); // column 1 img[row] = loadImage(code+".gif"); PImage img = loadImage(code+".gif"); image(img, 0, 0); img.resize(0, 50); //img.resize(surface, gnp); image(img, 0, 0); } } void draw() { background(255); // Drawing attributes for the ellipses smooth(); fill(192, 0, 0); noStroke(); // Loop through the rows of the locations file and draw the points int x = 500; int y = 0; //int x = surface; //int y = gnp; for (int row = 0; row < rowCount; row++) { String code = locationTable.getString(row, 0); // column 1 image(img[row],x,y); //Float x = locationTable.getFloat(row, 1); // column 1 //Float y = locationTable.getFloat(row, 2); // column 2 int gnp = locationTable.getInt(row, 2); int surface = locationTable.getInt(row, 3); text(code+":"+gnp+":"+surface, x, y); y+=80; if (y>height) { x = gnp; y = surface; //y=20; //x+=150; //gnp = PImage img(code+"gif"); } } }