How to draw histogram in Processing
- by theolc
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!