In [ ]:
# pip install plotly==5.8.0
Collecting plotly==5.8.0 Using cached plotly-5.8.0-py2.py3-none-any.whl (15.2 MB) Collecting tenacity>=6.2.0 Using cached tenacity-8.0.1-py3-none-any.whl (24 kB) Installing collected packages: tenacity, plotly Successfully installed plotly-5.8.0 tenacity-8.0.1 Note: you may need to restart the kernel to use updated packages.
import libraries
In [ ]:
import pandas as pd
import numpy as np
import plotly.express as px
create data, use Dict
In [ ]:
data=pd.DataFrame({'latitude': {0: 37.9844383,
1: 37.987244200000006,
2: 37.9783811,
3: 37.9934691,
4: 37.9842815,
5: 37.9844383,
6: 37.9844383,
7: 39.29853170000001,
8: 39.29853170000001,
9: 39.29853170000001,
10: 38.2280667,
11: 38.2280667,
12: 38.0045679,
13: 37.9944925,
14: 38.0158537,
15: 38.0026161,
16: 37.9823979,
17: 37.9816306,
18: 37.9787307,
19: 37.9755042,
20: 37.977031200000006,
21: 37.9824516,
22: 37.9756512,
23: 37.9844383,
24: 37.9755042,
25: 37.9755042,
26: 37.9779718,
27: 37.9734542,
28: 37.9769393,
29: 40.6953398},
'longitude': {0: 23.7281172,
1: 23.726373100000004,
2: 23.7805126,
3: 23.7275065,
4: 23.7177254,
5: 23.7281172,
6: 23.7281172,
7: 22.3844827,
8: 22.3844827,
9: 22.3844827,
10: 21.7632893,
11: 21.7632893,
12: 23.7160906,
13: 23.7042077,
14: 23.7268584,
15: 23.7334402,
16: 23.6940037,
17: 23.7281396,
18: 23.7246486,
19: 23.73267610000001,
20: 23.7223758,
21: 23.730563,
22: 23.7340008,
23: 23.7281172,
24: 23.73267610000001,
25: 23.73267610000001,
26: 23.74299580000001,
27: 23.735698,
28: 23.743741600000003,
29: 23.2203643},
'count': {0: 1,
1: 3,
2: 4,
3: 4,
4: 2,
5: 4,
6: 9,
7: 4,
8: 4,
9: 7,
10: 12,
11: 9,
12: 20,
13: 5,
14: 15,
15: 12,
16: 1,
17: 4,
18: 1,
19: 2,
20: 1,
21: 1,
22: 2,
23: 3,
24: 2,
25: 2,
26: 1,
27: 2,
28: 2,
29: 1}})
In [ ]:
data.head()
Out[ ]:
latitude | longitude | count | |
---|---|---|---|
0 | 37.984438 | 23.728117 | 1 |
1 | 37.987244 | 23.726373 | 3 |
2 | 37.978381 | 23.780513 | 4 |
3 | 37.993469 | 23.727507 | 4 |
4 | 37.984282 | 23.717725 | 2 |
In [ ]:
fig = px.density_mapbox(data, lat='latitude', lon='longitude', z='count',
mapbox_style="stamen-terrain")
In [ ]:
fig
In [ ]:
最后一次修改于 2022-05-21