Hi there,
I’m a bit puzzled; I use Dash and Plotly at work, but the examples provided in the doc do not display any map; when executed as-is, I get the legends, but no map. They work on a private machine, though, even without Wifi, which is in contradiction with the question asked in the title of this topic…
For instance, the below code
import plotly.express as px
df = px.data.gapminder().query("year == 2007")
fig = px.scatter_geo(df, locations="iso_alpha",
size="pop", # size of markers, "pop" is one of the columns of gapminder
)
fig.show()
Shows a blank page with an empty figure in the browser;
The next one
import plotly.express as px
df = px.data.gapminder().query("year == 2007")
fig = px.scatter_geo(df, locations="iso_alpha",
color="continent", # which column to use to set the color of markers
hover_name="country", # column added to hover information
size="pop", # size of markers
projection="natural earth")
fig.show()
Only shows legends items, no map.
I tried with other data:
import io
import pandas as pd
import numpy as np
import plotly.express as px
df_1 = pd.read_csv(io.StringIO("""Paesi_principali,Value,iso_alpha
US, 20, USA
Italia, 11, ITA
Germania, 6, DEU
Messico, 5, MEX
India, 6, IND
Francia, 8, FRA
"""))
fig = px.scatter_geo(df_1, locations="iso_alpha",locationmode ="ISO-3",
color="iso_alpha", size="Value", projection="natural earth")
fig.show()
But again, no map.
I also tried without px.express:
import plotly.graph_objects as go
fig30 = go.Figure()
fig30.add_trace(go.Scattergeo(lon=[21.0936], lat=[7.1881], text=['Africa'], mode='text', geo='geo2'))
fig30.update_layout(geo2=go.layout.Geo(scope='africa', domain=dict(x=[0, 0.6], y=[0, 0.6])))
fig30.show(
)
And again, no map.
I tried to plot a scatter_mapbox, but once again,
df = px.data.carshare()
fig = px.scatter_mapbox(df, lat="centroid_lat", lon="centroid_lon", color="peak_hour", size="car_hours",
color_continuous_scale=px.colors.cyclical.IceFire, size_max=15, zoom=10,
mapbox_style="carto-positron")
fig.show()
the above does not show any map. I get the marker on the map, though. (Maybe both a token and internet access issue, here?)
One more:
df = px.data.election()
geojson = px.data.election_geojson()
fig = px.choropleth_mapbox(df, geojson=geojson, color="Bergeron",
locations="district", featureidkey="properties.district",
center={"lat": 45.5517, "lon": -73.7073},
mapbox_style="carto-positron", zoom=9)
fig.show()
gives:
But no map
This topic seems to be related: Px scatter_geo does not show map ERROR
I use plotly 5.13. Any clue regarding the possible cause of the problem?