Earthquake Dot Map

I am trying to make an earthquake dot map on which you could not only figure out its magnitude by the size, but also know its depth by moving your mouse into the circle. It seems that when I was trying to control multiply variable in the same file (e.g. longitude, latitude, magnitude and depth), there’s always wrong with my function and if…else…

import csv
def setup():
size(800,600)
f = open("quakes.csv")
global reader
reader = csv.reader(f)
header = reader.next()
background(255)
map = loadImage("map.jpg")
image (map,(width-640)/2,(height-320)/2)
def draw():
translate(width/2,height/2)

for row in reader:
latitude = float(row[0])
longitude = float(row[1])
magnitude = float(row[2])
stroke(155,0,0)
ellipse(longitude,latitude,magnitude*6,magnitude*6)

A failed version when I trying to add text:

import csv
def setup():
size(800, 600)
f = open("quakes.csv")
reader = csv.reader(f)
header = reader.next()

global depths
depths=[]
for row in reader:
depth = float (row[3])
depths.append(depth)

global latitudes
latitudes = []
for row in reader:
latitude = float (row[0])
latitudes.append(latitude)

global longtitudes
longtitudes = []
for row in reader:
longtitude = float (row[1])
longtitudes.append(longtitude)

def draw():
background(255)
depth0 = depths[9]
depth9=depths[9]
x=0
textSize(12)
text("Depth:",650,460)

for depth in depths:
for latitude in latitudes:
for longtitude in longtitudes:

leftEdge = x-longtitude/2
rightEdge = x+longtitude/2
upEdge = y+latitude/2
downEdge = y-latitude/2

if leftEdge < mouseX and mouseX < rightEdge and downEdge < mouseY and mouseY < upEdge:
text(depth,670,460)
else:
text(0,67,460)
x+=2.5
Like what you read? Give Jujie Xu a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.