# Box() - set boundary on the Y axis

**URL:** https://discourse.processing.org/t/box-set-boundary-on-the-y-axis/1959
**Category:** Coding Questions
**Created:** [July 21, 2018, 12:35pm UTC](https://discourse.processing.org/t/box-set-boundary-on-the-y-axis/1959 "2018-07-21T12:35:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Caitlin123](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Caitlin123](https://discourse.processing.org/u/Caitlin123)
#### Post date: [July 21, 2018, 12:35pm UTC](https://discourse.processing.org/t/box-set-boundary-on-the-y-axis/1959/1 "2018-07-21T12:35:54Z")

</div>

Hi all,

Very new to processing, essentially im trying to loop through a csv folder to create a bar graph. the bars will be 3d boxes. Using the below as an example, what i dont understand is, when using the box function, i want one end of the box to be stable, then vary along one direction (either go up or down -NOT both) depending on the value of y (from the below - the first box y = 20, the second y = 100 and third y = 150). It seems as i vary the y value, the relative boxe moves both up and down, instead im trying to get one end fixed at the value of the line and just get the other end to vary.

thanks in advance and sorry if this is a very basic question.

size(500,500,P3D);

pushMatrix();  
translate(180, 200, 50);  
box (10, 20, 30);  
popMatrix();

pushMatrix();  
translate(150, 200, 50);  
box (10, 100, 30);  
popMatrix();

pushMatrix();  
translate(130, 200, 50);  
fill(250);  
box (10, 150, 30);  
popMatrix();

line(0, 200, 200, 200);

---

<div class="post-metadata">

### Author: ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)
#### Post date: [July 21, 2018, 1:13pm UTC](https://discourse.processing.org/t/box-set-boundary-on-the-y-axis/1959/2 "2018-07-21T13:13:32Z")

</div>

The problem is that the `box()`es are drawn centered on the point you are translating to. To make their bases all line up, you need to translate them upward an amount that is half the height.

Consider:

```auto
size(500,500,P3D);

pushMatrix();
translate(180, 200, 50);
translate(0,-10,0);
box (10, 20, 30);
popMatrix();

pushMatrix();
translate(150, 200, 50);
translate(0,-50,0);
box (10, 100, 30);
popMatrix();

pushMatrix();
translate(130, 200, 50);
fill(250);
translate(0,-75,0);
box (10, 150, 30);
popMatrix();

line(0, 200, 200, 200);

```

---

<div class="post-metadata">

### Author: ![Caitlin123](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Caitlin123](https://discourse.processing.org/u/Caitlin123)
#### Post date: [July 22, 2018, 8:26pm UTC](https://discourse.processing.org/t/box-set-boundary-on-the-y-axis/1959/3 "2018-07-22T20:26:41Z")

</div>

thanks mate - works perfectly.
