Application of Features of Plotly in Dash such as "landcolor"

I am not an experienced user of dash, I would kindly ask for your support.

Here I have a chart resulted by plotly:

cmap = matplotlib.cm.Blues(np.linspace(0,1,40))
CCC= cmap[4]
fig = go.Figure()
fig.add_trace(go.Scattergeo(
                    lon = MEDIUM.Longitude,
                    lat = MEDIUM.Latitude,
                    text = MEDIUM['txt'],
                    marker_color='green',
                    marker_size=8 ))
fig.update_layout(width = 675, height=900,
        title_text = 'Medium Earthquake zones',title_x=0.5,
        showlegend = False,
        geo = dict(
            scope = 'europe',
            resolution = 50,
            lonaxis_range= [ 6.6, 18.4 ],
            lataxis_range= [35.47, 47.25],
            landcolor = CCC,
        )
    )
#x axis
fig.update_xaxes(visible=False)

#y axis
fig.update_yaxes(visible=False)
fig.show()

Which gives me suitable chart:

Then when I want to use it inside the dash (to create interactive charts for each dot) my map becomes very small and land color becomes white. the code is :

app.layout = html.Div([  # this Div contains our scatter plot
    dcc.Graph(
        id='mpg_scatter',
        figure={
            'data': [go.Scattergeo(
                                lon = MEDIUM.Longitude,
                                lat = MEDIUM.Latitude,
                                text = MEDIUM['Codice Hotel'],
                                marker_color='green',
                                marker_size=8
            )],
            'layout': go.Layout(
                title = 'Medium Earthquake zones',
                hovermode='closest',
                showlegend = False,
                geo = dict(
                    scope = 'europe',
                    resolution = 50,
                    lonaxis_range= [ 6.6, 18.4 ],
                    lataxis_range= [35.47, 47.25],
                    landcolor='grey'
                 )
            )
    })]
, style={'height':'100vh','width':'100vh'})


if __name__ == '__main__':
    app.run_server()

and the dash becomes like below photo:

Can you please help me? Every source to understand better is appreciated.

Thanks in advanced.

Hi @Cna and welcome to the Dash community :slight_smile:

If you add ‘showland=True,’ to the geo dict in the layout, it should work.

I’m not sure why that’s required in the dash version and not when you just use fig.show(). I just compared your example to the last example in the docs on this page: Scatter plots on maps in Python

1 Like

Dear AnnMariew,
That was the solution thank you so much.

1 Like