Earthquakes that happened
Published in
1 min readOct 11, 2017
This interface visualizes the earthquake data over the past year.
import csv
def setup():
size(500,500)
with open("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(255)
noStroke()
scalar=15
x = 0
text("The earthquake occured with a magnitude of",10,300)
for magnitude in magnitudes:
leftEdge = x - 2
rightEdge = x + 2
if leftEdge < mouseX and mouseX < rightEdge:
fill(153,0,201)
text(str(magnitude),260,300)
else:
fill(203,203,203)
rect(x, height/2, 4, -magnitude*scalar)
x += 5