#!bpy
"""
Name: 'bar-diagramm'
Blender: 2.7x
Group: 'Mathematics'
Tooltip: 'bar-diagram'
"""

import bpy

def show(data =[1,2,3,4]):
    """ Show values a bar diagram """
    # get the context
    scn = bpy.context.scene
    for i in data:
        z = i
        bpy.ops.mesh.primitive_cube_add(location=(i * 3, 0, 0))

        # new position for the 3dcursor
        bpy.context.scene.cursor_location = (i * 3 , 0, -1)
        bpy.ops.object.origin_set(type='ORIGIN_CURSOR') 

        obj = bpy.context.object
        obj.scale[2] = i


if __name__ == '__main__':
    # Edit-Mode verlassen, fall notwendig
    if bpy.ops.object.mode_set.poll():
        bpy.ops.object.mode_set(mode='OBJECT')

    # Alle Meshobjekte aus der Szene loeschen
    bpy.ops.object.select_by_type(type='MESH')
    bpy.ops.object.delete() 
    show()