【发布时间】:2022-01-09 19:21:34
【问题描述】:
我想在下面的第二条轨迹上为每个 marker_color 添加一个图例,但我不知道如何通过图形对象实现它。 有什么想法吗?
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(
go.Scattergeo(
lat = df_outliers['Lat'],
lon = df_outliers['Long'],
marker = {'color' : 'grey',
'size': 5,
'symbol': 'diamond'},
name = "Stations outside clusters"
)
)
fig.add_trace(
go.Scattergeo(
lat = df_clusters['Lat'],
lon = df_clusters['Long'],
mode = 'markers',
marker_color = df_clusters['Clus_Db']
)
)
fig.update_layout(width=800, height=500,
margin=dict(r=0, b=20, l=0, t=50),
title = {
'text': "Weather Station in Canada",
'y':0.95,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top' },
geo_scope='north america'
)
fig.show()
【问题讨论】:
标签: python object plotly legend trace