Created
May 27, 2020 15:06
-
-
Save dsibi/cae93eac1cedfc1c931a4b2138d20275 to your computer and use it in GitHub Desktop.
Meteors
Meteors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In the code below I have marker labels on the map itself. | |
# I put this piece of code: | |
# float(d) + 5 for d in df["longitude"]], | |
# lat=[float(d) + 0 for d in df["latitude"]] | |
# to make these labels close to the markers. But in case of resizing of map these labels looks weird. | |
# I believe that it is possible to put into condition of labels position not only absolute values | |
# as it is now, but some sort of dependency between labels coordinates and values in data. | |
import plotly.express as px | |
import plotly.graph_objs as go | |
import pandas as pd | |
rows=[['501-600','15','122.58333','45.36667'], | |
['till 500','4','12.5','27.5'], | |
['more 1001','41','-115.53333','38.08'], | |
] | |
colmns=['bins','data','longitude','latitude'] | |
df=pd.DataFrame(data=rows, columns=colmns) | |
df = df.astype({"data": int}) | |
tag = " " + df['data'].astype(str) | |
fig=px.scatter_geo(df,lon='longitude', lat='latitude', | |
color='bins', | |
opacity=0.5, | |
size='data', | |
projection="natural earth") | |
fig.update_traces(hovertemplate ='bins') | |
fig.add_trace(go.Scattergeo(lon=[float(d) + 0 for d in df["longitude"]], | |
lat=[float(d) + 0 for d in df["latitude"]], | |
text = tag, | |
textposition="middle right", | |
mode='text', | |
showlegend=False)) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment