You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在go.Scattergeo中根据数值列表设置标记大小与颜色?

基于counts列表调整Scattergeo标记的大小/颜色

你可以通过在go.Scattergeo的marker参数中绑定counts列表,实现标记大小或颜色的动态调整,具体方案如下:

1. 调整标记大小

通过marker.size绑定counts,还可通过缩放系数或sizemode优化显示效果:

fig = go.Figure(data=go.Scattergeo(
        mode = 'markers',
        lon = long,
        lat = lat,
        marker=dict(
            size=[c * 2 for c in counts],  # 用缩放系数调整标记尺寸,可按需修改
            sizemode='area'  # 可选,让大小基于面积变化,视觉上更直观
        )
))

fig.update_layout(geo_scope='europe', width=1200, height=800)
fig.update_geos(showsubunits=True)
fig.show()

2. 调整标记颜色

通过marker.color绑定counts,搭配颜色刻度条展示数值对应关系:

fig = go.Figure(data=go.Scattergeo(
        mode = 'markers',
        lon = long,
        lat = lat,
        marker=dict(
            color=counts,  # 直接关联counts数值
            colorscale='Viridis',  # 可选颜色方案,比如'RdYlBu'、'Plasma'
            colorbar=dict(title='Counts')  # 添加颜色刻度条,标注数值含义
        )
))

fig.update_layout(geo_scope='europe', width=1200, height=800)
fig.update_geos(showsubunits=True)
fig.show()

3. 同时调整大小和颜色

将上述两种配置结合,实现双重维度的视觉区分:

fig = go.Figure(data=go.Scattergeo(
        mode = 'markers',
        lon = long,
        lat = lat,
        marker=dict(
            size=[c * 2 for c in counts],
            sizemode='area',
            color=counts,
            colorscale='Viridis',
            colorbar=dict(title='Counts')
        )
))

fig.update_layout(geo_scope='europe', width=1200, height=800)
fig.update_geos(showsubunits=True)
fig.show()

内容的提问来源于stack exchange,提问作者Christian01

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 06:45:31