-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_plot_map.py
57 lines (44 loc) · 1.46 KB
/
simple_plot_map.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Andrés González SJ
# https://github.com/andrescg2sj
#
import plotly.graph_objs as go
from plotly.offline import plot
state_codes = ["AL", "AK", "AZ", "AR", "CA",
"CO", "CT", "DE", "DC", "FL",
"GA", "HI", "ID", "IL", "IN",
"IA", "KS", "KY", "LA", "ME",
"MD", "MA", "MI", "MN", "MS",
"MO", "MT", "NE", "NV", "NH",
"NJ", "NM", "NY", "NC", "ND",
"OH", "OK", "OR", "PA", "RI",
"SC", "SD", "TN", "TX", "UT",
"VT", "VA", "WA", "WV", "WI", "WY"]
values = [3, 5, 2, 4, 9,
10, 0, 3, 5, 7,
3, 6, 5, 5, 5,
6, 1, 4, 3, 9,
8, 3, 9, 2, 7,
5, 9, 4, 9, 2,
6, 6, 6, 5, 8,
7, 3, 10, 1, 8,
8, 6, 8, 4, 10,
4, 0, 7, 2, 2, 6]
data = dict(type='choropleth',
locations=state_codes,
locationmode='USA-states',
text=state_codes,
z=values,
colorscale="Plasma"
)
#For other color scales, see:
# https://plotly.com/python/builtin-colorscales/#builtin-sequential-color-scales
layout = dict(geo = dict(scope='usa',
showlakes= False),
title="Some measure"
)
choromap = go.Figure(data=[data], layout=layout)
#This should launch a web browser and show the map on it.
plot(choromap)
#Write the map to disk
choromap.write_html("example_map.htm")