How to draw histogram in Processing

Posted by theolc on Stack Overflow See other posts from Stack Overflow or by theolc
Published on 2012-10-21T22:57:14Z Indexed on 2012/10/21 23:00 UTC
Read the original article Hit count: 139

Filed under:

I have an arrayList and I would like to take the size of the ten arrayList elements and use the sizes to create a histogram. I understand processing coordinate system starts in the top left corner. My question is, how do I use the arrayList.size() values to start at 450 (based from a 500,500 window) and go upwards from there to create my histogram.

The following is my function for the histogram, it is receiving as a parameter the arrayList called bins.

    void histogram(ArrayList[] bins) {
    //set window  
    background(0,0,0);
    size(500,500); 
    background(255,255,255);
    line(50,0,50,500);
    line(0,450,500,450);
    int i;
    for (i = 50; i <= 500; i+=45) { 
       line(i,450,i,480);    
    }
    for (i = 50; i <= 450; i+=45) { 
       line(50,i,20,i);    
    }

  }

Thanks in adavance for any help and input!

© Stack Overflow or respective owner

Related posts about processing