【问题标题】:Option "symbol" in scattermapbox is not workingscattermapbox 中的选项“符号”不起作用
【发布时间】:2020-01-07 12:35:04
【问题描述】:

我正在尝试将符号从圆圈更改为位置图钉以突出显示地图上的坐标。但是,除了“圆圈”之外,符号选项中没有其他选项可以正常工作。 我已经尝试过 - 正方形、标记、三角形。有人可以告诉我如何解决这个问题,它不会引发错误

#Plotting co-ordinates on to the map
    fig = go.Figure(go.Scattermapbox
            (
            lat=df["Latitude"],
            lon=df["Longitude"],
            mode='markers',
            marker=go.scattermapbox.Marker
                (
                       size=10,
                       color =  df['Size'],
                       colorscale = 'RdYlGn_r',
                       showscale=True,
                       symbol = 'star'
                 )
                )

【问题讨论】:

    标签: python google-maps scatter-plot


    【解决方案1】:

    在 plotly 文档中,他们使用另一种语法来执行此操作,您是否已经尝试过?

    import plotly.graph_objects as go
    
    token = open(".mapbox_token").read() # you need your own token
    
    fig = go.Figure(go.Scattermapbox(
        mode = "markers+text+lines",
        lon = [-75, -80, -50], lat = [45, 20, -20],
        marker = {'size': 20, 'symbol': ["bus", "harbor", "airport"]},
        text = ["Bus", "Harbor", "airport"],textposition = "bottom right"))
    
    fig.update_layout(
        mapbox = {
            'accesstoken': token,
            'style': "outdoors", 'zoom': 0.7},
        showlegend = False)
    
    fig.show()
    

    来源:https://plot.ly/python/scattermapbox/#set-marker-symbols

    【讨论】:

      【解决方案2】:

      请注意,与“圆形”(默认)不同的标记仅在您使用需要为其提供 mapbox 令牌的“来自 Mapbox 服务的矢量图块”(例如“深色”或“卫星”)时才有效;但如果您使用“open-street-map”等“开放”矢量图块,它们就不起作用

      【讨论】:

        猜你喜欢
        • 2022-01-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多