I tried to create several maps and saved as png files. In cycle I got all mapes per year. I want to add which year on the map, and I tried title=i and fig.update_layout(title_text=i, title_x=0.5), but it does not work.
import plotly.express as px
import pandas as pd
year = [1980,1981,1983]
lat = [60.572959, 60.321403, 56.990280]
lon = [40.572759, 41.321203, 36.990299]
dataframe = pd.DataFrame(list(zip(year,lat,lon)),
columns =['year', 'lat', 'lon'])
for idx, i in enumerate(sorted(dataframe['year'].unique())):
#for x in range(1980,2022):
sp = sp1[sp1['year']==i]
fig = px.scatter_mapbox(dataframe, lat='lat', lon="lon",
color_discrete_sequence=["fuchsia"], zoom=2, height=400, opacity=0.3, title = i)
fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.update_layout(title_text=i, title_x=0.5)
fig.write_image("all/plot{idx}.png".format(idx=idx))
I put the picture of one map as example. I want to add year for every map in any place.

>Solution :
Use the annotations attribute of the previously created layout object in the update_layout method to add text – specified by the x and y coordinates.
fig.update_layout(annotations=[
dict(text=i, x=0.5, y=0.5, font_size=15, showarrow=False)
])
Play around with the x and y coordinates to find the proper position you want to place your text at.