Earthquake stacked bar graph

Weijian Bi
Data Mining the City
1 min readSep 27, 2017

I was using lab computer, but it didn’t allowed me to use screen recorder software to get a gif.

Code:

import csv
def setup():
size(800, 200)

with open('\Documents\Processing\Assignment_3\sketch_170927b\quakes.csv') as f:
reader = csv.reader(f)
header = reader.next() # Skip the header row.

global magnitudes

magnitudes = []
for row in reader:
magnitude = float(row[4])
magnitudes.append(magnitude)


def draw():
background(0)
scalar=10
x = 0


for magnitude in magnitudes:

upperEdge = x
lowerEdge = x + 20

line(0,height/2,width,height/2)

if upperEdge < mouseX and mouseX < lowerEdge:
fill(255,0,0)
rect(x, height/2, 5,(magnitude*scalar)*(-1))
else:
fill(255,255,255)
rect(x, height/2, 5 , (magnitude*scalar)*(-1))
x += 5

--

--