Created
February 19, 2023 19:38
-
-
Save catslovedata/646c9dca60d78faab0fcf63d44f7d766 to your computer and use it in GitHub Desktop.
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
import plotly.io as pio | |
import plotly.express as px | |
pio.renderers.default = 'notebook' | |
# px.set_mapbox_access_token('SET_ME') | |
fig = px.scatter_mapbox( | |
df, | |
lat='latitude', | |
lon='longitude', | |
#hover_name='shopping_centre', | |
#hover_data= { | |
# 'region': False, | |
# 'longitude': False, | |
# 'latitude': False, | |
# 'city_town': True, | |
# 'size_sq_m': True | |
#}, | |
custom_data=['shopping_centre', 'longitude', 'latitude', 'city_town', 'size_sq_m'], | |
color='size_sq_m', | |
opacity=0.6, | |
color_continuous_scale='Electric', | |
size='size_sq_m', | |
mapbox_style='carto-positron', | |
# mapbox_style='basic' # Requires setting a mapbox access token: px.set_mapbox_access_token('SET_ME') | |
width=1000, | |
height=800, | |
zoom=5, | |
) | |
fig.update_layout( | |
hoverlabel=dict( | |
bgcolor='#eeeeee', | |
bordercolor='#666666', | |
font_size=20, | |
font_family='Bebas Neue', | |
font_color='#333333', | |
), | |
title=dict( | |
text='U.K. Shopping Centres by size', | |
font_size=42, | |
font_family='Bebas Neue', | |
font_color='black', | |
x=0.5, | |
y=0.95 | |
), | |
margin_t=100 | |
) | |
fig.update_coloraxes( | |
colorbar=dict( | |
exponentformat='none', | |
len=0.5, | |
orientation='v', | |
tickfont_family='Bebas Neue', | |
tickfont_size=20, | |
tickfont_color='#666', | |
), | |
colorbar_title=dict( | |
text='Area (sq.m)', | |
font_size=30, | |
font_family='Bebas Neue', | |
font_color='#333', | |
side='right', | |
) | |
) | |
fig.update_traces( | |
hovertemplate='<b>%{customdata[0]}</b><br>%{customdata[3]}<br>%{customdata[4]:,} sq.m' | |
) | |
fig.update_mapboxes( | |
center_lat=54, | |
center_lon=-2.5, | |
) | |
fig.add_annotation( | |
text='Source: https://en.wikipedia.org/wiki/List_of_shopping_centres_in_the_United_Kingdom_by_size', | |
showarrow=False, | |
x=0.5, | |
y=-0.05, | |
font_family='Ubuntu Light', | |
) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment