plotly / plotly/plotly.py

`fitbounds="locations"` parameter not working for `px.choropleth_map`

Open
#4,262 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3 size: 1
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

The fitbounds parameter appear not to work when used in choropleth mapbox. The only way I found to pass it to the Figure object was to use the update_geos method.

The following is a sample of the code to show the parameter used:

fig = px.choropleth_mapbox(
        df, 
        geojson=self.geojson,
        featureidkey=self.featureidkey,
        locations="location_code,
        color=self.metric,
        mapbox_style="carto-positron",
        opacity=0.4
    )
fig.update_geos(fitbounds="locations")

When calling fig.show, the plot opens to the (0,0) location in Gulf of Guinea.

Why the fitbounds parameter doesn't work on choropleth mapbox?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided px.choropleth_mapbox example and inspect how fitbounds is handled by choropleth_mapbox versus update_geos. Trace the figure-generation entry point and confirm the map centers on the supplied locations instead of (0,0); document a focused regression check for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.