簡體   English   中英

plotly go 散點圖框未顯示標記

[英]plotly go Scattermapbox is not showing markers

我怎么遇到了一些奇怪的錯誤。 當我嘗試創建 Scattermapbox 時,標記不會呈現。 這個錯誤不知從何而來,它工作得很好,然后我的 inte.net 出了問題,現在在過去的 8 個小時里它一直沒有工作。

我試過在不同的 IDE 中運行它,在 google colab 中運行它以確保它不是我的機器不同的數據集。

我不確定我做錯了什么

但是,當我 hover 在不可見點上時,工具提示會顯示。 工具提示不可見

如果使用導出到 png 按鈕,則會顯示所有內容。

在此處輸入圖像描述

但無論它在實際的 map 本身上出現什么,我都束手無策。

我將在下面包含回調 function。

@app.callback(
    Output('2dmap','figure'),
    [Input('2dgraph', 'clickData'),
    Input('checklist', 'value')])
def update_map_2d(clickData,checklist):
   
# =============================================================================
#     P1. Render Map when no point is clicked
# =============================================================================
    # If No point has been clicked
    if clickData is None:
        #make a map
        maps2d = go.Figure(go.Scattermapbox(
            lat=[], # set lat and long
            lon=[],
            mode='markers', 
            marker =({'size':5.5}) # make markers size variable 
        ))
    
        # set up map layout
        maps2d.update_layout(
            autosize=True, # Autosize
            hovermode='closest', # Show info on the closest marker
            showlegend=True, # show legend of colors
            mapbox=dict(
                accesstoken=mapbox_access_token, # token
                bearing=0, # starting facing direction
                # starting location
                center=dict(
                    lat=td.cLat,
                    lon=td.cLong
                ),
                #angle and zoom
                pitch=0,
                zoom=12
            ),
            #height and width
            width=1000,
            height=1000
        )
        return maps2d
    else:

       
        xCoord = int(clickData['points'][0]['x'])
        yCoord = int(clickData['points'][0]["y"])
        
        
        
        solutionRow = preatoFrontier.loc[(preatoFrontier['x'] == xCoord)&(preatoFrontier['y'] == yCoord)]

        solId = int(solutionRow['SolId'])

        #solId = 49

        solution = td.getSolution(solutions, solId)       

        color = []
        for row in solution['upGrade']:
            if row == 0:
                color.append('grey')
            if row == 1:
                color.append('green')
            if row == 2:
                color.append('blue')
            if row == 3:
                color.append('red')

        solution['color'] = color
        solution2 = solution[solution['color'].isin(checklist)]
         
        maps2d = go.Figure(go.Scattermapbox(
            lat=solution2['lat'],
            lon=solution2['long'],
            mode='markers', 
            #marker =({'color':solution['color']},{'size':5.5})
            
            marker=dict(
                        size=12,
                        color=solution2['color'], #set color equal to a variable
                        colorscale='Viridis', # one of plotly colorscales
                        showscale=True
                    )

        ))
        
#=============================================================================
# P3. Map Layout
#=============================================================================
        
        #set up map layout
        maps2d.update_layout(
            autosize=False, # Autosize
            hovermode='closest', # Show info on the closest marker
            showlegend=True, # show legend of colors
            mapbox=dict(
                accesstoken=mapbox_access_token, # token
                bearing=0, # starting facing direction
                # starting location
                center=dict(
                    lat=td.cLat,
                    lon=td.cLong
                ),
                #angle and zoom
                pitch=0,
                zoom=10
            ),
            #height and width
            width=1000,
            height=1000
        )

        return maps2d  

經過一番糾結之后,我想嘗試創建一個新的 venv 並一個一個地上傳包並運行以查看失敗的方式和位置。 我在它壞掉之前安裝的最后一個 package 是dash-tools並且肯定是一些導致 mapbox 嚴重錯誤的原因。 所以不要安裝dash-tools

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM