1

My current code is

def drawBarChart(b1, b2, b3):
  x = 300
  y = 320
  if b1 > y:
    y = b1 + 100
  if b2 > y:
    y = b2 + 100
  if b3 > y:
    y = b3 + 100
  pic1 = makeEmptyPicture(x, y)
  bar(pic1, 60, b1, 40, red)
  bar(pic1, 140, b2, 40, blue)
  bar(pic1, 220, b3, 40, green)
  show(pic1)

def bar(pic1, startX, c, width, colour):
  y = 320
  if c > y:
    y = c
  addRectFilled(pic1, startX, 0, width, c, colour)

and while it works in creating three different coloured bars, they're all upside down (they start at the top of the picture). Is there something I'm doing that's making them start at the top? I'm a beginner, so please try not to add in libraries, or any advanced stuff. My code must be in the format it's in, as it's for a school assignment.

Austin
  • 29
  • 3
  • Just a thought: In math, `x` goes upwards as it increases. In programming `x` falls, so `(0, 0)` is the *top*-left corner. Maybe you have your `x`s inverted? – Carl Smith Oct 07 '14 at 19:52

1 Answers1

0

Try just replace this line of code in your function bar addRectFilled(pic, startX, 320-height, width, height, shade) it might help you!