I would like to put subtitles on my Density Mapbox subplots.
My code looks like:
gear = 'trawlers'
flag = "GBR"
df_UK_fishing = df[(df.flag == flag) & (df.geartype == gear)]
df_UK_fishing['flag'].value_counts()
data = []
months = df_UK_fishing['Month'].unique()
# months = ['January', 'February']
fig = go.Figure()
COLS = 4
ROWS = 3
x = 0
y = ROWS
for i in range(len(months)):
df_tmp = df_UK_fishing[df_UK_fishing['Month'] == months[i]]
mapbox = 'mapbox'+str(i+1) if i != 0 else 'mapbox'
fig.add_trace(
go.Densitymapbox(
lat=df_tmp.cell_ll_lat,
lon=df_tmp.cell_ll_lon,
name = months[i],
z=df_tmp.fishing_hours,
radius = 4,
subplot=mapbox,
zmin=0,
zmax=25,
)
)
fig.update_layout({
mapbox:{
'style': 'open-street-map',
'domain': {'x': [float(x)/float(COLS), float(x+1)/float(COLS)], 'y': [float(y-1)/float(ROWS), float(y)/float(ROWS)]},
'center': {'lat': cen_lat, 'lon':cen_lon},
'zoom': 4,
# 'layers': [{
# "sourcetype": "raster",
# "sourceattribution": str(months[i]),
# "source": [
# "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
# ]
# }]
},
'meta':{
mapbox:{
'title':{'text':months[i]},
'dragmode': False,
'margin': {"r":30, "t":30,"l":30,"b":30},
'showlegend': True,
}
}
})
x = x+1
if x >= COLS:
y=y-1
x = 0
if y <= 0:
y = ROWS
# fig.update_coloraxes(showscale=False)
fig.update_layout(
margin={"r":0, "t":30,"l":0,"b":0},
title = f"2019 monthly fishing data for {flag} {gear}",
)
Which produces:
However if you change fig.update_layout()
so that 'style': 'white-bg'
and uncomment the 'layers'
section then it should produce a chart like this (with subplot titles, which is something Iād like to add to my chart).
Any tips on how I might get my densityplot with my subchart-titles?