Make a histogram from data read from file

Hello! Im new to processing, trying to learn on my own.. Im doing some exercises, but this one got me stuck. I have a .csv file with 12 values in it, and im supposed to make a histogram (bar graph) from these values. Can anyone please tell me how to do that?

The values are both + and - so that means the graph cannot start at a 0 value.. it also has to show the negative values.

This is the code i got so far (might be all wrong!)

int[] data;

void setup(){

 String[] grader=loadStrings("grader.csv");
 data= int(split(grader[0],","));


void draw(){
 for (int x=0; x < data.length; x++){


  • Answer ✓
    int[] data = {5,20,25,60,30,80,2,1,0,90,100,180};
    void setup() { 
      size(500, 500); 
      fill(255, 0, 0, 30);
      //String[] grader=loadStrings("grader.csv"); 
      //data= int(split(grader[0], ",")); //println(grader[0]);
    void draw() { 
      for (int x=0; x < data.length; x++) { 
        rect(25*x, height-data[x], 20, data[x]);
  • Thanks, but i need to load the values to be used in the graph from the file grader.csv.. thats where the problem comes inn.. cos when i do that it only displays one graph..

  • Oh, sorry. It's tough to spot issues in code you can't run.

      String[] grader=loadStrings("grader.csv");
      String[] lineOne = grader[0].split(",");
      for(int i=0; i<lineOne.length;i++){
        data[i] = int(lineOne[i]);
Sign In or Register to comment.