plotly / plotly/plotly.py

Layer disappears if zoomed out. Reappears when zooming.

Open
#2,811 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Issue:
Objects will disappear if the zoom level of the graph is increased to a certain amount.

Demo:

  • image

  • Image 1: Zoomed out version of a graph

  • image

  • Image 2: Zoomed in version of the same graph

Specifications:
Plotly Version: 4.10.0

Code:

I included pickled versions of the buildable land / trackers objects here. They are geodataframes.

    # --- Set up base map ---
    fig = go.Figure(go.Scattermapbox())
    fig.update_layout(
        mapbox_accesstoken = token,
        mapbox_style = "mapbox://styles/skrhee/ckbtiaefh0wrr1hp7h4ya3zy4",
        mapbox_zoom = 13,
        mapbox_center = {'lon': centroid_lon, 'lat': centroid_lat},
        margin = {'l':0, 'r':0, 'b':0, 't':0},
        height = 500
        )
     
    layers = []
    # --- Add buildable polygons ---
    full_buildable = MultiPolygon(list(buildable_land['geometry']))
    obj = gd.GeoSeries(full_buildable).to_json()
    poly_json = json.loads(obj)
    
    layer = {
        'source': poly_json,
        'type': "fill",
        'below': "traces",
        'color': "royalblue",
        'opacity': 0.65
        }
    layers.append(layer)
    
    # --- Add tracker polygons ---
    trackers = gd.read_file(df['AL_0.0'][0])
    full_trackers = MultiPolygon(list(trackers['geometry']))
    obj = gd.GeoSeries(full_trackers).to_json()
    poly_json = json.loads(obj)
    
    layer = {
        'source': poly_json,
        'type': "fill",
        'below': "traces",
        'color': "royalblue",
        'opacity': 0.65
        }
    layers.append(layer)


    
    # --- Update Figure ---
    fig.update_layout(
        mapbox = {
            'layers': layers
            }
        )

    st.plotly_chart(fig, use_container_width=True)


[pickles.zip](https://github.com/plotly/plotly.py/files/5343508/pickles.zip)






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 behavior with the mapbox layers configured in fig.update_layout and rendered through st.plotly_chart. Verify whether the polygon layers remain visible across zoom levels, using the supplied code and pickles if they can be loaded; done means the layers no longer disappear when zooming out.

Written by the indexing model from the issue text.

Assessment

Tech stack
plotly, python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.