plotly.py: Choropleth_mapbox and FigureWidget - 'mapbox._derived' Value Error
When plotting a choropleth_mapbox using plotly express and containing it within a figure widget, I am encountering a ValueError when I drag the plot around. The error does not affect the interactivity of the plot, but it does create a huge error log in the output. I thought about trying go.add_choroplethmapbox(), but realized that the arguments are different from the plotly express version.
I have included a sample code below.
Plotly [offline] jupyter core : 4.6.3 jupyter-notebook : 6.0.3 ipywidgets : 7.5.1 traitlets : 4.3.3 plotly : 4.8.1
import plotly.express as px
import plotly.graph_objs as go
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.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
figwid = go.FigureWidget(fig)
display(figwid)
ValueError:
Invalid property path 'mapbox._derived' for layout
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 19 (2 by maintainers)
I’m also having the same issue. Are there any updates on when this will be addressed?
Here you go. https://github.com/macadology/plotly_binder https://mybinder.org/v2/gh/macadology/plotly_binder/master?filepath=%2Fmin_code.ipynb
Once the plot is generated, moving it or interacting with it will cause error messages to appear in the output cell below the plot.
Just run this to do @macadology 's edit.
Hello, just to note that I also have the same issue with a scatter mapbox plot. Using add_scattermapbox does not seem to help. Here is a minimal reproducer:
Yay, glad to hear back from the development team.
I tried it again from a clean environment too and I encountered the same error. See below for my setup using conda and pip. For convenience, I didn’t specify a particular version but instead rely on pip to resolve the latest version.
When running the min code in a jupyter notebook environment, the error message appears whenever I interact with the plot. Below is a screenshot of the actual error. Is it possible the development team tested the code outside of the notebook environment? Let me know if I should create a mybinder notebook to reproduce the error.
Added a temporary hack in
basedatatypes.py
to skip the exception specifically for mapbox._derived and it seems to work for now.