6
6
extension : .md
7
7
format_name : markdown
8
8
format_version : ' 1.2'
9
- jupytext_version : 1.5.1
9
+ jupytext_version : 1.4.2
10
10
kernelspec :
11
11
display_name : Python 3
12
12
language : python
@@ -20,14 +20,14 @@ jupyter:
20
20
name : python
21
21
nbconvert_exporter : python
22
22
pygments_lexer : ipython3
23
- version : 3.7.4
23
+ version : 3.7.7
24
24
plotly :
25
25
description : How to make a map with Hexagonal Binning of data in Python with Plotly.
26
- display_as : scientific
26
+ display_as : maps
27
27
language : python
28
28
layout : base
29
29
name : Hexbin Mapbox
30
- order : 7
30
+ order : 13
31
31
page_type : u-guide
32
32
permalink : python/hexbin-mapbox/
33
33
redirect_from : python/hexbin-mapbox/
@@ -55,7 +55,7 @@ fig.update_layout(margin=dict(b=0, t=0, l=0, r=0))
55
55
fig.show()
56
56
```
57
57
58
- #### Count Hexbin with Minimum Count
58
+ #### Count Hexbin with Minimum Count and Opacity
59
59
60
60
``` python
61
61
import plotly.figure_factory as ff
@@ -66,13 +66,13 @@ df = px.data.carshare()
66
66
67
67
fig = ff.create_hexbin_mapbox(
68
68
data_frame = df, lat = " centroid_lat" , lon = " centroid_lon" ,
69
- nx_hexagon = 10 , opacity = 0.9 , labels = {" color" : " Point Count" },
69
+ nx_hexagon = 10 , opacity = 0.5 , labels = {" color" : " Point Count" },
70
70
min_count = 1 ,
71
71
)
72
72
fig.show()
73
73
```
74
74
75
- #### Display the Underlying Data
75
+ #### Display the Underlying Data
76
76
77
77
``` python
78
78
import plotly.figure_factory as ff
@@ -83,7 +83,7 @@ df = px.data.carshare()
83
83
84
84
fig = ff.create_hexbin_mapbox(
85
85
data_frame = df, lat = " centroid_lat" , lon = " centroid_lon" ,
86
- nx_hexagon = 10 , opacity = 0.9 , labels = {" color" : " Point Count" },
86
+ nx_hexagon = 10 , opacity = 0.5 , labels = {" color" : " Point Count" },
87
87
min_count = 1 , color_continuous_scale = " Viridis" ,
88
88
show_original_data = True ,
89
89
original_data_marker = dict (size = 4 , opacity = 0.6 , color = " deeppink" )
@@ -96,6 +96,7 @@ fig.show()
96
96
``` python
97
97
import plotly.figure_factory as ff
98
98
import plotly.express as px
99
+ import numpy as np
99
100
100
101
px.set_mapbox_access_token(open (" .mapbox_token" ).read())
101
102
df = px.data.carshare()
@@ -113,6 +114,7 @@ fig.show()
113
114
``` python
114
115
import plotly.figure_factory as ff
115
116
import plotly.express as px
117
+ import numpy as np
116
118
117
119
px.set_mapbox_access_token(open (" .mapbox_token" ).read())
118
120
df = px.data.carshare()
@@ -138,7 +140,7 @@ np.random.seed(0)
138
140
N = 500
139
141
n_frames = 12
140
142
lat = np.concatenate([
141
- np.random.randn(N) * 0.5 + np.cos(i / n_frames * 2 * np.pi)
143
+ np.random.randn(N) * 0.5 + np.cos(i / n_frames * 2 * np.pi) + 10
142
144
for i in range (n_frames)
143
145
])
144
146
lon = np.concatenate([
@@ -152,6 +154,7 @@ frame = np.concatenate([
152
154
fig = ff.create_hexbin_mapbox(
153
155
lat = lat, lon = lon, nx_hexagon = 15 , animation_frame = frame,
154
156
color_continuous_scale = " Cividis" , labels = {" color" : " Point Count" , " frame" : " Period" },
157
+ opacity = 0.5 , min_count = 1 ,
155
158
show_original_data = True , original_data_marker = dict (opacity = 0.6 , size = 4 , color = " deeppink" )
156
159
)
157
160
fig.update_layout(margin = dict (b = 0 , t = 0 , l = 0 , r = 0 ))
0 commit comments