1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
from pylab import *
from scipy import *
import json
# reading the data from a csv file
# durl = 'http://datasets.flowingdata.com/crimeRatesByState2005.csv'
# rdata = genfromtxt(durl,dtype='S8,f,f,f,f,f,f,f,i',delimiter=',')
f = open('list04', 'r')
data = json.loads(f.read())
rdata[0] = zeros(8) # cutting the label's titles
rdata[1] = zeros(8) # cutting the global statistics
x = []
y = []
color = []
area = []
print(rdata)
for data in rdata:
x.append(data[1]) # murder
y.append(data[5]) # burglary
color.append(data[6]) # larceny_theft
area.append(sqrt(data[8])) # population
# plotting the first eigth letters of the state's name
text(data[1], data[5],
data[0],size=11,horizontalalignment='center')
# making the scatter plot
sct = scatter(x, y, c=color, s=area, linewidths=2, edgecolor='w')
sct.set_alpha(0.75)
axis([0,11,200,1280])
# xlabel('Murders per 100,000 population')
# ylabel('Burglaries per 100,000 population')
# show()
savefig('img')
|