Magnitude of Earthquake
Published in
1 min readSep 27, 2017
import csvdef setup():
size(800, 300)
with open("quakes.csv.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)
ellipse(80, 80, 80, 80)def draw():
background(0)
scalar=20
x = 0
for magnitude in magnitudes:
leftEdge = x - (magnitude * scalar) / 2
rightEdge = x + (magnitude * scalar) / 2
if leftEdge < mouseX and mouseX < rightEdge:
fill(255,0,0)
else:
fill(255,255,255)
rect(x, height/1.5, magnitude*scalar/6, (magnitude*scalar*3)*(-1))
x += 8
textSize(20)
text("The magnitude of the earthquake on Sep.27", 200,250)